How to use tr1 with Visual Studio 2010 (tr1 :: function)?

How to start using tr1 functions in Visual Studio 2010? For a more specific case, I need the function std :: tr1 ::. I tried to include #include <tr1/functional> , which reports that it is missing, and #include <functional> includes a penalty, but when I installed this:

 std::tr1::function<void(void)> callback; 

I get:

 1>d:\marmalade\projects\core\src\button.h(21): error C3083: 'tr1': the symbol to the left of a '::' must be a type 1>d:\marmalade\projects\core\src\button.h(21): error C2039: 'function' : is not a member of '_STL' 1>d:\marmalade\projects\core\src\button.h(21): error C2143: syntax error : missing ';' before '<' 1>d:\marmalade\projects\core\src\button.h(21): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>d:\marmalade\projects\core\src\button.h(21): error C2238: unexpected token(s) preceding ';' 

If I use boost, it works fine, but for this project, due to the use of a certain structure, I will need the tr1 version for Visual Studio.

As suggested, skipping tr1 will still return the same result:

 std::function<void(void)> callback; 1>d:\marmalade\projects\core\src\button.h(20): error C2039: 'function' : is not a member of '_STL' 1>d:\marmalade\projects\core\src\button.h(20): error C2143: syntax error : missing ';' before '<' 1>d:\marmalade\projects\core\src\button.h(20): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>d:\marmalade\projects\core\src\button.h(20): error C2238: unexpected token(s) preceding ';' 
+8
c ++ c ++ 11 std visual-studio-2010 tr1
source share
2 answers

Based on your comments and on this page , I think Marmalade comes with its own version of STL, which looks outdated. This page confirms that they are using a version of STLPort that does not support TR1, which was released in 2005, and much less than the new one. Your options:

1) Copy / write them yourself
2) It is necessary without 3) Download a newer version of STLPort . It seems that it has not been updated in the last two years, so there is no C ++ 11, but they mention the presence of functional , but it is unclear whether it is in the std or std::tr1 . However, this may not work with Marmalade, so do backups and be careful.

+8
source share

Visual Studio 2010 comes with C ++ 11 enabled by default (or at least what is implemented). You need to use std::function<void(void)> .

See the full table here .

Aside: you shouldn't use anything from TR1 these days. It has been integrated into the new standard.

+2
source share

All Articles