std::find_if takes a predicate in one of it's overloaded function. Binders make it possible to write EqualityComparators for user-defined types and use them either for dynamic comparison or static comparison.
In contrast the binary search functions of the standard library take a comparator and a const T& to the value that should be used...
Hi. I'm working on a 64-bit Linux system, trying to build some code that depends on third-party libraries for which I have binaries. During linking, I get a stream of undefined reference errors for one of the libraries, indicating that the linker couldn't resolve references to standard C++ functions/classes, e.g.:
librxio.a(EphReader...
I know Visual Studio 2010's standard library has been rewritten to support rvalue references, which boosts its performance considerably.
Does the standard library implementation of gcc 4.4 (and above) support rvalue references?
...
When writing C++ code is there any difference between:
#include <cstdlib>
and
#include <stdlib.h>
other than the former being mostly contained within the std:: namespace?
Is there any reason other than coding standards and style to use one over the other?
...
Hi,
I have this windows console app which takes a file, do some calculations, and then writes the output to a specified file. The input is specified in "app.exe -input fullfilename" format. I need to call this application from my C++ program, but I have a problem with spaces in paths to files. When I call the app directly from cmd.exe b...
Hey,
where would I place additions to stdlib classes in a rails project? Let's say something like:
class Date
def foo
'foo'
end
end
I thought about the initializer folder but it somehow felt wrong. Ideas?
...
Why does ZeroMemory, and similar calls exist in the Windows API when there are memset and related calls in the C standard library already? Which ones should I call? I can guess the answer is "depends". On what?
...
I've tried to learn the signal handling in C, when found strange behaviour.
When x /= y; executed in the context of the main function the signal handler works. But when the same executed in some function (bad_func) handler is ignored however signal handler for SIGFPE is already set.
Q: Why SIGFPE wasn't caught in a function by my globa...
I am writing a program to read info from a text file and I had everything working. The problem is that I am trying to add the functionality to calculate the mean of some of fields and have to convert the strings to doubles. I noticed that atof would work in some cases but would return -1 for the most part. i then realized that I didn'...
I am making a simple application which requires colored output. How can I make my output colored like emacs and bash do?
I don't care about Windows, as my application is only for UNIX systems.
Thanks.
...
I've read that qsort is just a generic sort, with no promises about implementation. I don't know about how libraries vary from platform to plaform, but assuming the Mac OS X and Linux implementations are broadly similar, are the qsort implementations recursive and/or require a lot of stack?
I have a large array (hundreds of thousands of...
I want to derive from std::back_insert_iterator to create a kind of filter for a string type, say back_xml_insert_iterator, that will examine the characters passed through it looking for characters that can not be emitted "naked" into an XML stream, e.g., '"', '&', '<', '>', and '\'', and will on-the-fly insert their character entity ref...
I wrote this function to read a line from a file:
const char *readLine(FILE *file) {
if (file == NULL) {
printf("Error: file pointer is null.");
exit(1);
}
int maximumLineLength = 128;
char *lineBuffer = (char *)malloc(sizeof(char) * maximumLineLength);
if (lineBuffer == NULL) {
printf("Err...
I quite like being able to generate the same set of pseudo-random data repeatedly, especially with tweaking experimental code. Through observation I would say that rand() seems to give the same sequence of numbers each time*.
Is it guaranteed to do this for repeated executions on the same machine / for different machines / for different...
Couldn't find_if just be an overload of find? That's how std::binary_search and friends do it...
...
I'm pretty new to C++, but I know you can't just use memory willy nilly like the std::string class seems to let you do. For instance:
std::string f = "asdf";
f += "fdsa";
How does the string class handle getting larger and smaller? I assume it allocates a default amount of memory and if it needs more, it news a larger block of memory ...
Let me start with explaining what I mean with "magic". I will use two examples from Java:
Every class inherits (directly or indirectly) the Object class.
Operator overloading is not supported by Java but the + operator is defined for String objects.
This means that it is impossible to make an implementation of the Object and String c...
I thought I read about a C standard library function recently that was able to return a pointer to any extern variable whose name was passed to it as a const char *. I think that it works via linker symbols, if that helps.
...
I was just wondering if there was anything in the C++0x std lib already available to count the number of parameters in a parameter pack? I'd like to get rid of the field_count in the code below. I know I can build my own counter, but it just seems like this would be an obvious thing to include in the C++0x std lib, and I wanted to be s...
I'm attempting to implement the atomic library from the C++0x draft. Specifically, I'm implementing §29.6/8, the store method:
template <typename T>
void atomic<T>::store(T pDesired, memory_order pOrder = memory_order_seq_cst);
The requirement states:
The order argument shall not be memory_order_consume, memory_order_acquire, nor...