c++0x

Can someone please explain move semantics to me?

I just finished listening to the Software Engineering talk radio podcast interview with Scott Meyers regarding C++0x. Most of the new features made sense to me and I am actually excited about C++0x now, with the exception of one. I still don't get "Move Semantics"... What are they exactly? ...

Where is disable_if in C++0x?

Boost has both enable_if and disable_if, but C++0x seems to be missing the latter. Why was it left out? Are there meta-programming facilities in C++0x that allow me to build disable_if in terms of enable_if? Oh, I just noticed that std::enable_if is basically boost::enable_if_c, and that there is no such thing as boost::enable_if in C...

How to implement C++0x raw string literal?

How to define a working set of lexer and parser (exempli gratia: flex and bison) to support the C++0x styled raw string literals? As you may already know, new string literals in C++0x can be expressed in a very flexible way. R"<delim>...<delim>"; - in this code the <delim> can be pretty much everything and also no escape characters...

Question about rvalue in C++0x

I create many times I use class DataBuffer in many places in code, so it should be fast and lightweight. Moreover I use various buffer sizes, so to reduce memory allocations I wrote such template: template<unsigned int T_buffer_size> class DataBuffer { public: DataBuffer (const unsigned int &buffer_size); char buffe...

Is there a simple way to forward to a member function with a matching function signature?

Is there a simple way to forward to a member function with a matching function signature? typedef std::tr1::function<int(int,int,int,int)> TheFn; class C { int MemberFn(int,int,int,int) { return 0; } TheFn getFn() { //is there a simpler way to write the following line? return [this](int a,int b,int c,int d){ r...

Forwarding all constructors in C++0x

What is the correct way to forward all of the parent's constructors in C++0x? I have been doing this: class X: public Super { template<typename... Args> X(Args&&... args): Super(args...) {} }; ...

Do rvalue references allow implicit conversions?

Is the following code legal? std::string&& x = "hello world"; g++ 4.5.0 compiles this code without any problems. ...

In C++, is it still bad practice to return a vector from a function?

Short version: It's common to return large objects—such as vectors/arrays—in many programming languages. Is this style now acceptable in C++0x if the class has a move constructor, or do C++ programmers consider it weird/ugly/abomination? Long version: In C++0x is this still considered bad form? std::vector<std::string> BuildLargeVector...

difference between cstdint and tr1/cstdint

What is the difference between <cstdint> and <tr1/cstdint>? (apart from that one puts things in namespace std:: and the other in std::tr1::) Since this stuff isn't standard yet I guess it's compiler specific so I'm talking about gcc. To compile with the non-tr1 one I must compile with -std=c++0x, but there is no such restriction when us...

Scope of pure virtual functions during derived class destruction - In C++

Hi, During destruction of the derived class object, i first hit the derived class destructor and then the base class destructor (which is as expected). But i was curious to find out - at what point does the functions of the derived class go out of scope (are destroyed). Does it happen as soon as the control leaves the derived class des...

supporting for each loop in classes

hi how can i add "for each" support for my class in c++0x and visual studio 2010? ...

Combine two constant strings (or arrays) into one constant string (or array) at compile time

In C# and Java, it's possible to create constant strings using one or more other constant strings. I'm trying to achieve the same result in C++ (actually, in C++0x, to be specific), but have no idea what syntax I would use to achieve it, if such a thing is possible in C++. Here's an example illustrating what I want to do: #include <st...

Should lambda decay to function pointer in templated code?

I read somewhere that a lambda function should decay to function pointer if the capture list is empty. The only reference I can find now is n3052. With g++ (4.5 & 4.6) it works as expected, unless the lambda is declared within template code. For example the following code compiles: void foo() { void (*f)(void) = []{}; } But it do...

Returning address of local variable or temporary when using C++0x decltype return value

Edit: This is indeed a bug in the compiler, I've opened a defect and got the following response. Hello Motti, Thank you for submitting this issue. As noted in the stackoverflow posting, this is a bug in our decltype implementation. Unfortunately, we cannot fix this bug in the next release of Visual Studio since the code is relativ...

What is the type of a lambda function?

In C++0x, I'm wondering what the type is of a lambda function. Specifically: #include<iostream> type1 foo(int x){ return [x](int y)->int{return x * y;}; } int main(){ std::cout<<foo(3)(4);//would output 12 type2 bar = foo(5); std::cout<<bar(6);//would output 30 return 0; } What do I need to replace type1/type2 with to get the...

Difference between angle bracket < > and double quotes " " while including header files in C++?

Possible Duplicate: what is the difference between #include <filename> and #include filename What is the difference between angle bracket < > and double quotes " " while including header files in C++? I mean which files are supposed to be included using eg: #include and which files are to be included using eg: #include "MyFi...

Why is there no way to undo 'using' in C++?

I've often found myself wanting a way to undo the effect of a using statement or to include all of a namespace (such as std) but exclude a bit to be replaced (such as cout). For some reason this isn't possible. I am wondering if anyone knows why it was decided not to add this ability to the language? Is there some technical reason? I ass...

C++0x - lambda expression does look same as Java's anonymous inner class?

Is my interpretation of lambda expression in the context of c++ and Java is correct? ...

To use or not to use C++0x features

Possible Duplicate: How are you using C++0x today? I'm working with a team on a fairly new system. We're talking about migrating to MSVC 2010 and we've already migrated to GCC 4.5. These are the only compilers we're using and we have no plans to port our code to different compilers any time soon. I suggested that after we do ...

Taking the Address of a Temporary, with a Twist

I have a function address_of, which returns a Pointer (encapsulating a shared_ptr) to its argument. address_of needs to work on both lvalues and rvalues, so there are two versions of address_of: one accepting a reference and the other accepting an rvalue reference. Since taking the address of a temporary is a Bad Thing, the rvalue versio...