std-tr1

shared_ptr in std::tr1

I am working on a platform with a gcc compiler however boost cannot compile on it. I am wondering what is the proper way to include the shared_ptr in std:tr1 on gcc? the file i looked in said not to include it directly, from what i can tell no other file includes it either :| ...

C++ TR1: how to use the normal_distribution ?

Hi, I'm trying to use the C++ STD TechnicalReport1 extensions to generate numbers following a normal distributions, but this code (adapted from this article): mt19937 eng; eng.seed(SEED); normal_distribution<double> dist; // XXX if I use the one below it exits the for loop // uniform_int<int> dist(1, 52); for (unsigned int i = 0;...

C++ a NULL pointer in the STL container

Hello! I am, unfortunately, not working on a program developed by myself fully. I recently I noticed a Visual Studio Fatal Error on operator-- of unordered_set, which was called from simple insertion of a pointer to unordered_set. After reviewing the locals, I've noticed that set only has 2 elements last of which is NULL (so I suppose ...

Link TR1 on Ubuntu?

I have written a class using std::tr1::regex, and I don't know how to link it. I get (sorry for the large dump...) : $ g++ DictReader.cpp -std=c++0x /usr/include/c++/4.4/tr1_impl/regex:2255: warning: inline function ‘bool std::tr1::regex_search(_Bi_iter, _Bi_iter, std::tr1::match_results<_Bi_iter, _Allocator>&, const std::tr1::basic_re...

Why is std::tr1::shared_ptr<>.reset() so expensive?

Profiling some code that heavily uses shared_ptrs, I discovered that reset() was surprisingly expensive. For example: struct Test { int i; Test() { this->i = 0; } Test(int i) { this->i = i; } } ; ... auto t = make_shared<Test>(1); ... t.reset(somePointerToATestObject); Tracing the reset() in th...

std::tr1::function and std::tr1::bind

I have a problem using a very complicated C function in a C++ class (rewriting the C function is not an option). C function: typedef void (*integrand) (unsigned ndim, const double* x, void* fdata, unsigned fdim, double* fval); // This one: int adapt_integrate(unsigned fdim, integrand f, void* fdata, ...

Preventing keys of different hash values from landing in same bucket with unordered_set

This might be a silly question, but here goes : I hashed a dictionary of words into an unordered_set based hash-table. My hash function was made intentionally "bad", in that all strings that contained the same set of letters would hash to the same value. I initially tried to over-ride the normal hash function behaviour, and use a "freq...