tr1

Replacing native VS 2010 (VC10) tr1 libraries with Boost.TR1

杀马特。学长 韩版系。学妹 提交于 2019-12-06 11:00:10
I have been using VS 2005 (VC8) with Boost.TR1 in the std::tr1 namespace by setting the Include Directories of VS to prioritize the boost tr1 headers as described here . Now I am moving over to VS 2010 (VC10) and I seem to be getting compilation errors using the same include method. The Include Directories are set to: [boost-root]\boost\tr1\tr1 [boost-root] VC standard include directories Sample code: #include <functional> #include <iostream> int main(int argc, char ** argv) { std::cout << std::tr1::bind(std::minus<int>(), 5, std::tr1::placeholders::_1)(5) << std::endl; return 0; } Build

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

人走茶凉 提交于 2019-12-06 05:23:26
问题 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, unsigned dim, const double* xmin, const double* xmax, unsigned maxEval, double reqAbsError, double reqRelError, double* val, double* err); I need to supply a void function of type integrand myself

tr1::mem_fn and members with default arguments

淺唱寂寞╮ 提交于 2019-12-05 12:39:02
I have class with a member function that takes a default argument. struct Class { void member(int n = 0) {} }; By means of std::tr1::mem_fn I can invoke it: Class object; std::tr1::mem_fn(&Class::member)(object,10); That said, if I want to invoke the callable member on the object with the default argument, what's the correct syntax? std::tr1::mem_fn(&Class::member)(object); // This does not work g++ complains with the following error: test.cc:17: error: no match for call to ‘(std::tr1::_Mem_fn<void (Class::*)(int)>) (Class&)’ /usr/include/c++/4.3/tr1_impl/functional:551: note: candidates are:

How to check for TR1 while compiling?

牧云@^-^@ 提交于 2019-12-05 11:05:31
We are programming a logging library that keeps itself in a .hpp file. We would like to include <tr1/unordered_map> (if the compiler supports TR1,) or the standard <map> otherwise. Is there a standard way of checking at compile time if tr1 is available or not? I was thinking that the same way that the " __cplusplus " define symbol is present, there could have been defined a " __cxx__tr1 " or something like that. I haven't seen that in the drafts for TR1, so I assume it is not present, but I wanted to ask first just in case. As a note, if those defines don't exist, it wouldn't be a bad idea to

Is it legal to place using tr1::shared_ptr in namespace std in header?

久未见 提交于 2019-12-04 12:53:23
问题 Is it legal and good programming style to use std::tr1::shared_ptr as std::shared_ptr placing using directive in corresponding header ? Like this: namespace std { using tr1::shared_ptr; } I know that it's bad to pollute entire namespace but what about this case? Are there any hidden gotchas? Target compiler is VS2008 but compatibility with later versions is also desired. 回答1: Technically, the Standard says that you enter the realm of Undefined Behavior if you do this: 17.6.4.2.1 Namespace std

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

谁说胖子不能爱 提交于 2019-12-04 09:43:27
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, unsigned dim, const double* xmin, const double* xmax, unsigned maxEval, double reqAbsError, double reqRelError, double* val, double* err); I need to supply a void function of type integrand myself, and adapt_integrate will calculate the n-dimensional integral. The code in calcTripleIntegral (below)

How to access target of std::tr1::shared_ptr in GDB

百般思念 提交于 2019-12-04 03:26:34
How can I access target of a std::tr1::shared_ptr in GDB. This doesn't work: (gdb) p sharedPtr->variableOfTarget If I try with the pointer object itself ( p sharedPtr ) I get something like this: $1 = std::tr1::shared_ptr (count 2) 0x13c2060 With a normal pointer I can do p *ptr and get all the data or p ptr->variable for just one variable. I'm on Centos 6.5, GCC 4.4.7-4.el6 and GDB 7.2-64.el6_5.2. Try with (gdb) p (*sharedPtr.get()) that function returns the a pointer to the object owned by the smart pointer. ptr->get() not always work. when i try ptr->get(), gdb complains for: can not

shared_ptr in std::tr1

一个人想着一个人 提交于 2019-12-04 02:49:40
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 :| bdonlan In G++ 4.3 , #include <tr1/memory> should do the trick. You'll find shared_ptr at std::tr1::shared_ptr . Boost itself has the answer . Boost can not compile on it? Most of the boost library doesn't need to be compiled to be used, and I guess shared_ptr doesn't either. 来源: https://stackoverflow.com/questions/471438

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

女生的网名这么多〃 提交于 2019-12-03 23:57:19
问题 Are there any difference between tr1::shared_ptr and boost::shared_ptr ? If so, what? 回答1: No, the documentation of boost shared_ptr says: This implementation conforms to the TR1 specification, with the only exception that it resides in namespace boost instead of std::tr1. 来源: https://stackoverflow.com/questions/3831572/differences-between-tr1shared-ptr-and-boostshared-ptr

Defining a hash function in TR1 unordered_map inside a struct

。_饼干妹妹 提交于 2019-12-03 13:56:24
问题 According to this, it is possible to define an equality function in a TR1 unordered_map like this: #include <tr1/unordered_map> using namespace std; using namespace std::tr1; struct foo{ ... bool operator==(const foo& b) const{ return ..; } }; unordered_map<foo,int> map; Is it possible to define the hash function the same way? 回答1: If you want to change the default hashing (or, more often, provide hashing for a type that isn't currently supported), you provide a specialization of std::tr1: