standard-library

Does C or C++ have a standard regex library?

限于喜欢 提交于 2019-12-02 22:43:23
Does it? If yes, where can I get the documentation for it... if not, then which would be the best alternative? Joris Timmermans C++11 now finally does have a standard regex library - std::regex. If you do not have access to a C++11 implementation, a good alternative could be boost regex . It isn't completely equivalent to std::regex (e.g. the "empty()" method is not in the std::regex ) but it's a very mature regex implementation for C++ none the less. Under UNIX-like systems you can use POSIX regex functions . The Microsoft Visual C++ 2008 Feature Pack 1 (now rolled into the Visual Studio 2008

Memory leak in Go http standard library?

谁说胖子不能爱 提交于 2019-12-02 19:27:51
Have a Go binary implement an http server: package main import ( "net/http" ) func main() { http.ListenAndServe(":8080", nil) } It will start with ~850 kb or so of memory. Send it some requests via your web browser. Observe it quickly rises to 1 mb. If you wait, you'll see it never goes down. Now hammer it with Apache Bench (using the script below) and see your memory usage continually increase. After sometime it will eventually plateau at around 8.2 MB or so. Edit: It doesn't seem to stop at 8.2, rather it slows down significantly. It's currently at 9.2 and still rising. In short, why is this

ECMAScript Regex for a multilined string

别说谁变了你拦得住时间么 提交于 2019-12-02 17:59:50
问题 I am writing the loading procedure for my application and it involves reading data from a file and creating an appropriate object with appropriate properties. The file consists of sequential entries (separated by a newline) in the following format: === OBJECT TYPE === <Property 1>: Value1 <Property 2>: Value2 === END OBJECT TYPE === Where the values are often strings which may consist of arbitrary characters, new-lines, etc. I want to create a std::regex which can match this format and allow

Where can I find all the exception guarantees for the Standard Containers and Algorithms?

泄露秘密 提交于 2019-12-02 17:35:46
Yes, I've looked at the C++ standards that I could find (or the drafts), but I'm not finding any comprehensive of the exception guarantees given by STL containers. All I can find are occasional sections with incomplete descriptions on some of the functions for some of the types. Or perhaps it's there but I'm just not finding it, I don't know. Note: I'm not asking for a list of all the guarantees people can think of, which is basically in this question . I'm looking for the authoritative source of this information itself -- or preferably, a free version of the source (e.g. a draft of the

Member function pointer issue with standard library methods

邮差的信 提交于 2019-12-02 16:33:39
问题 This question is spawned from Passing a member function pointer to an overloaded class method into a template function. You need not read that to understand this question. Probably both the questions will have the same answer. I am getting compiler error for below simple code. #include<set> template<typename Return, typename T> T ReceiveFuncPtr (Return (T::*Method)(const int&)) { T obj; // Found and declared an object of actual container class (obj.*Method)(1); // Some processing return obj;

Most useful Python modules from the standard library? [closed]

房东的猫 提交于 2019-12-02 13:49:11
I am teaching a graduate level Python class at the University of Paris, and the students need to be introduced to the standard library. I want to discuss with them about some of the most important standard modules. What modules do you think are absolute musts? Even though responses probably vary depending on your field (web programming, science, etc.), I feel that some modules are commonly needed: math , sys , re , os , os.path , logging ,… and maybe: collections , struct ,… What modules would you suggest I present, in a 1 or 2 hour slot? Modules to cover in a 1-2 hour slot entirely depend on

ECMAScript Regex for a multilined string

旧巷老猫 提交于 2019-12-02 13:17:08
I am writing the loading procedure for my application and it involves reading data from a file and creating an appropriate object with appropriate properties. The file consists of sequential entries (separated by a newline) in the following format: === OBJECT TYPE === <Property 1>: Value1 <Property 2>: Value2 === END OBJECT TYPE === Where the values are often strings which may consist of arbitrary characters, new-lines, etc. I want to create a std::regex which can match this format and allow me to use std::regex_iterator to read each of the objects into the file in turn. However, I am having

Member function pointer issue with standard library methods

时光总嘲笑我的痴心妄想 提交于 2019-12-02 11:08:14
This question is spawned from Passing a member function pointer to an overloaded class method into a template function . You need not read that to understand this question. Probably both the questions will have the same answer. I am getting compiler error for below simple code . #include<set> template<typename Return, typename T> T ReceiveFuncPtr (Return (T::*Method)(const int&)) { T obj; // Found and declared an object of actual container class (obj.*Method)(1); // Some processing return obj; // Returned that container class object with RVO } int main () { ReceiveFuncPtr(&std::set<int>:

C++ ofstream delete and cleanup

删除回忆录丶 提交于 2019-12-02 08:44:48
问题 I am writing a C++ ofstream that sometimes must be cleaned up - the file I am writing to should be deleted and the class deleted and cleaned up. How? (Except closing it and deleting it by name). (At least the file should not exist with the intended location and filename with which it was opened - tempfile directory could be OK) 回答1: As far as I know, there is no other way. Close the file and use remove with its name. This is probably best handled by some sort of RAII class; I regularly use an

Is strncpy() a specialization of memcpy()?

拟墨画扇 提交于 2019-12-02 05:12:50
Just curious to know (as we use these functions often). I don't see any practical difference between strncpy() and memcpy() . Isn't it worth to say that effectively, char* strncpy (char *dst, const char *src, size_t size) { return (char*)memcpy(dst, src, size); } Or am I missing any side effect? There is one similar earlier question , but couldn't find an exact answer. There is a difference, see this part of the strncpy page you linked to (emphasis mine): Copies the first num characters of source to destination. If the end of the source C string (which is signaled by a null-character) is found