standard-library

Where can I see the list of functions that interact with errno?

喜你入骨 提交于 2019-12-03 12:44:02
In the book "The C Programming Language" it says: "Many of the functions in the library set status indicators when error or end of file occur. These indicators may be set and tested explicitly. In addition, the integer expression errno (declared in <errno.h> ) may contain an error number that gives further information about the most recent error." Where can I see a list of these functions? The standard says this about errno : The value of errno is zero at program startup, but is never set to zero by any library function. The value of errno may be set to nonzero by a library function call

Why is numCapabilities a pure function?

自闭症网瘾萝莉.ら 提交于 2019-12-03 09:47:49
In the concurrency library GHC.Conc there is a function called numCapabilities . Its type is numCapabilities :: Int and it actually returns some number you passed by the command line flag (e.g. 5 if the options are +RTS -N 5 ). However, getArgs (type: IO [String] ) does essentially the same (it returns the unparsed non-runtime arguments) but isn't a pure function. If the only excuse is that numCapabilities is often needed in pure code, in what way aren't other command line options not needed in pure code? Am I something missing or is either numCapabilities a design flaw or am I allowed to

Good Idea / Bad Idea Should I Reimplement Most Of C++? [closed]

人盡茶涼 提交于 2019-12-03 09:30:36
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . Recently, I've got a dangerous idea into my head after reading this blog post. That idea can be expressed like this: I don't need most of what the C++ standard library offers. So, why don't I implement a less general, but easier to use version? As an example, using the STL

Memory leak in Go http standard library?

谁说胖子不能爱 提交于 2019-12-03 05:59:08
问题 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

How to workaround the inconsistent definition of numeric_limits<T>::min()?

旧巷老猫 提交于 2019-12-03 05:51:29
The numeric_limits traits is supposed to be a general way of obtaining various type infomation, to be able to do things like template<typename T> T min(const std::vector<T>& vect) { T val = std::numeric_limits<T>::min(); for(int i=0 ; i<vect.size() ; i++) val = max(T, vect[i]); return val; } The problem is that (at least using MS Visual Studio 2008) numeric_limits<int>::min() returns the smallest negative number, while numeric_limits<double>::min() returns the smallest positive number! Anyone knows the rationalie behind this design? Is there a better (recommended?) way of using numeric_limits?

Boost dependency for a C++ open source project?

℡╲_俬逩灬. 提交于 2019-12-03 05:36:30
问题 Boost is meant to be the standard non-standard C++ library that every C++ user can use. Is it reasonable to assume it's available for an open source C++ project, or is it a large dependency too far? 回答1: Basically your question boils down to “is it reasonable to have [free library xyz] as a dependency for a C++ open source project.” Now consider the following quote from Stroustrup and the answer is really a no-brainer: Without a good library, most interesting tasks are hard to do in C++; but

trim is not part of the standard c/c++ library?

筅森魡賤 提交于 2019-12-03 05:09:33
Is it me or are there no standard trim functions in the c or c++ library? is there any single function that acts as a trim? If not can anyone tell me Why trim is not part of the standard library? (i know trim is in boost) My trim code is std::string trim(const std::string &str) { size_t s = str.find_first_not_of(" \n\r\t"); size_t e = str.find_last_not_of (" \n\r\t"); if(( string::npos == s) || ( string::npos == e)) return ""; else return str.substr(s, e-s+1); } test: cout << trim(" \n\r\r\n \r\n text here\nwith return \n\r\r\n \r\n "); -edit- i mostly wanted to know why it wasnt in the

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

北慕城南 提交于 2019-12-03 04:17:07
问题 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

Changing Java PriorityQueue to a Max PQ [duplicate]

旧巷老猫 提交于 2019-12-03 00:13:22
This question already has an answer here: Change priorityQueue to max priorityqueue 14 answers The Priority Queue implementation in the Java standard library appears to be a min Priority Queue which I found somewhat confusing. In order to turn it into a max one I created a custom comparator object. Comparator<Integer> cmp = new Comparator<Integer>() { public int compare( Integer x, Integer y ) { return y - x; } }; I was wondering if there was a more elegant solution. Essentially I wan't a generic priority queue that could be used to implement Dijkstras etc. I didn't even realise there would be

Good Idea / Bad Idea Should I Reimplement Most Of C++? [closed]

好久不见. 提交于 2019-12-02 23:51:50
Closed . This question is opinion-based. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . Recently, I've got a dangerous idea into my head after reading this blog post. That idea can be expressed like this: I don't need most of what the C++ standard library offers. So, why don't I implement a less general, but easier to use version? As an example, using the STL spits out reams of incomprehensible and mangled compiler errors. But, I don't care about allocators, iterators