tr1

gcc with boost for tr1, hash functor specialization

I am using boost for tr1 instead of gcc 4.5's native tr1 libraries (by prioritizing boost tr1 headers over gcc headers). There is a compile problem specializing std::tr1::hash. #include <functional> #include <memory> template <class A> struct std::tr1::hash< std::tr1::shared_ptr<A> > : public unary_function< std::tr1::shared_ptr<A>...

How to make tr1::array allocate aligned memory?

You can allocate a std::vector which allocates aligned heap memory by defining your own allocator. You can allocate a c-style array on the stack using declspec align. But can you declare a tr1::array which guarantees that the element at index zero will be aligned? ...

Is there a native/reliable alternative for boost::shared_ptr in VC++ ?

My company doesn't allow the use of boost (for many stupid reasons, but that's off-topic). I feel very frustrated having to use raw pointers when I'm used to shared_ptr, weak_ptr and scoped_ptr for personal development. We're working exclusively with Microsoft compilers (Visual Studio 2010) and I wonder if there was an alternative to t...

tr1::regex regex_search problem

Hey all, I'm using tr1::regex to try to extract some matches from a string. An example string could be asdf werq "one two three" asdf And I would want to get out of that: asdf werq one two three asdf With stuff in quotes grouped together, so I'm trying to use the regex \"(.+?)\"|([^\\s]+). The code I'm using is: cmatch res...

Why is std::function not equality comparable?

This question also applies to boost::function and std::tr1::function. std::function is not equality comparable: #include <functional> void foo() { } int main() { std::function<void()> f(foo), g(foo); bool are_equal(f == g); // Error: f and g are not equality comparable } The operator== and operator!= overloads are declared ...

Downloadable STL documentation that covers TR1?

For my offline coding needs, I've been using the downloadable STL documentation from SGI. Unfortunately it was last edited in 1999, and doesn't cover any of the TR1. It's easy enough to find online references for TR1, but can anybody recommend an easily downloadable TR1 reference for working offline? In HTML? I've downloaded Boost's ...

Is std::array<T, S> guaranteed to be POD if T is POD?

I'm currently writing a C++ memory editing library and for the read/write APIs I use type traits (std::is_pod, std::is_same) and boost::enable_if to provide 3 overloads: POD types. e.g. MyMem.Read(SomeAddress); String types. e.g. MyMem.Read>(SomeAddress); (This doesn't actually read out a C++ string, it reads out a C-style string and c...

Converting a lambda to a std::tr1::function

Using visual studio 2008 with the tr1 service pack and Intel C++ Compiler 11.1.071 [IA-32], this is related to my other question I'm attempting to write a functional map for c++ which would work somewhat like the ruby version strings = [2,4].map { |e| e.to_s } So i've defined the following function in the VlcFunctional namespace te...

Virtual member functions and std::tr1::function: How does this work?

Here is a sample piece of code. Note that B is a subclass of A and both provide a unique print routine. Also notice in main that both bind calls are to &A::print, though in the latter case a reference to B is passed. #include <iostream> #include <tr1/functional> struct A { virtual void print() { std::cerr << "A" << std:...

Using C++ Technical Report 1 (TR1) in VC++ 2010

How do I use a C++ TR1 library in visual c++ 2010? ...

Call c++ member function with each element in a list?

I have a list of Thing and a Controller that I want to notify() with each of the things. The code below works: #include <algorithm> #include <iostream> #include <tr1/functional> #include <list> using namespace std; class Thing { public: int x; }; class Controller { public: void notify(Thing& t) { cerr << t.x << endl; } }; class N...

Differences between tr1::shared_ptr and boost::shared_ptr?

Are there any difference between tr1::shared_ptr and boost::shared_ptr? If so, what? ...

Using C++0x TR1 random in a class, for low overhead

Hello, I'm using VC 2010 and trying to keep the overhead and duplicated code of certain functions low, by placing the random definitions in the constructor of each class instance, then calling as necessary from there. What I have now, simplified, is: #include <random> #include <Windows.h> mt19937 eng(GetTickCount()); class Cycles { ...

error while using regex_replace function from <tr1/regex>

#include <string> #include <tr1/regex> #include "TextProcessing.h" const std::string URL_PATTERN("((http://)[-a-zA-Z0-9@:%_\\+.~#?&amp;//=]+)"); const std::string REPLACEMENT("<a href=\"$&\"\">$&</a>"); std::string textprocessing::processLinks(const std::string & text) { // essentially the same regex as in the previous example, b...