Question

I use boost a lot in my code but have so far refrained from using std::tr1. Now I need a more sophisticated function pointer, like those two can provide. Unfortunately C+11 is not an option yet. I read that boost::function can be tricky with certain compilers e.g. (Visual Studio before 7.1 needs a special portable syntax) but have not found any information on std::tr1::function regarding this subject. Are there any important differences concerning memory usage, speed and compatibility between the two ?

Edit: I am currently using gcc 4.7 but the code should also compile on Visual Studio and preferably also slightly more dated versions like 2005

Was it helpful?

Solution

What did you read? What do you mean by tricky? Are you referring to some ancient compilers only supporting the boost::function1<void, int> form rather than boost::function<void(int)> form?

std::tr1::function should be provided by your compiler, so if your compiler provides it at all then it should work perfectly, and not be "tricky" (whatever you mean by that.)

Asking if there are differences between Boost's specific implementation and an interface specification, which is not an implementation, doesn't make sense. One implementation could be similar to Boost's and have no substantial differences and another implementation could be completely different. GCC's std::tr1::function was contributed by the author of Boost.Function, so it's very similar.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top