c++0x

C++ template overloading - wrong function called

template<typename T> T* Push(T* ptr); template<typename T> T* Push(T& ref); template<typename T, typename T1> T* Push(T1&& ref); I have int i = 0; Push<int>(i); But the compiler calls it ambiguous. How is that ambiguous? The second function is clearly the preferred match since it's more specia...

Configuring gcc compiler switches in Qt / QtCreator / QMake

I recently tried to use Qt Creator 1.3.2 / Qt 4.6.2 / gcc 4.4.0 (32-bit version) on Windows 7 (64-bit) to compile an application using some of the experimental C++0x extensions and encountered the following (fatal) error: This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently ...

C++0x is assignment of braced-init-list to an array correct?

n3092 (final draft) says, under 5.17/9 A braced-init-list may appear on the right-hand side of - an assignment to a scalar [...] - an assignment defined by a user-defined assignment operator [..] While in GCC 4.5.1-pre9999, I can compile this (using -std=c++0x, NOT -std=gnu++0x) #include <iostream> int main() { ...

Can a lambda expression be passed as function pointer?

I am trying to pass a lambda expression to a function that takes a function pointer, is this even possible? Here is some sample code, i'm using VS2010: #include <iostream> using namespace std; void func(int i){cout << "I'V BEEN CALLED: " << i <<endl;} void fptrfunc(void (*fptr)(int i), int j){fptr(j);} int main(){ fptrfunc(func,...

is there a way to use c++0x at xcode? I want to use gcc 4.4 or greater.

I want to use gcc 4.4 or greater for iphone developement. anyone know how? ...

rvalues and temporary objects in the FCD

It took me quite some time to understand the difference between an rvalue and a temporary object. But now the final committee draft states on page 75: An rvalue [...] is an xvalue, a temporary object or subobject thereof, or a value that is not associated with an object. I can't believe my eyes. This must be an error, right? To ...

What is the motivation behind c++0x lambda expressions?

I am trying to find out if there is an actual computational benefit to using lambda expressions in c++, namely "this code compiles/runs faster/slower because we use lambda expressions" OR is it just a neat development perk open for abuse by poor coders trying to look cool? Thanks. PS. I understand this question may seem subjective but ...

C++0x unique_ptr replaces scoped_ptr taking ownership?

I used to write code like this: class P {}; class Q: public P {}; class A { // takes ownership A(P* p): p_(p) {} scoped_ptr<P> p_; }; A a(new Q); With C++0x, should I rewrite class A as: class A { // takes ownership A(unique_ptr<P>&& p): p_(move(p)) {} unique_ptr<P> p_; }; ...

Move from *this in an rvalue method?

In C++0x, methods can be overloaded on whether or not the expression that denotes the object on which the method is called is an lvalue or an rvalue. If I return *this from a method called via an rvalue, do I need to explicitly move from *this or not? Foo Foo::method() && { return std::move(*this); // Is this move required or not?...

why aren't strongly typed C++0x enumerations comparable to each other?

why aren't strongly typed C++0x enumerations comparable to each other? ...

Question about r-value in C++0x

Rvalues IMHO are great improvement in C++, but at the beginning the're seems quite. Please look at code below: #include <string> std::string && foo (void) { std::string message ("Hello!"); return std::move (message); } void bar (const std::string &message2) { if (message2 == "Bye Bye!") return; } int main () { ...

Does any compiler support constexpr yet?

I want to play with constexpr, does any compiler support it yet? ...

Tips for submitting a library to Boost?

Hi everyone, Summer is coming, and a group of friends and I are getting ready for it :) We decided to build a compile-time Arbitrary precision Unsigned Integers. We would like to provide a set of integers algorithms(functions) with the library. We have seen a number of requests for such a library(SoC2010, C++0x Standard Library wishlis...

Can Boost Program_options separate comma separated argument values

If my command line is: > prog --mylist=a,b,c Can Boost's program_options be setup to see three distinct argument values for the mylist argument? I have configured program_options as: namespace po = boost::program_options; po::options_description opts("blah") opts.add_options() ("mylist", std::vector<std::string>>()->multitoken, ...

What is the difference between r-value references and l-value references? (CodeGen)

What does an r-value reference look like from a lower-level perspective. I just can't seem to wrap my head around it! Can I see an example of generated code (either equivalent C or x86/x64) from a r-value reference vs. a l-value reference? For example, what would this construct look like? Let's assume no copy elision for now. vector<So...

Socket pointer transfer of ownership with tcp::acceptor::async_accept

Hi all, I've recently started using Boost.Asio in a project and would like to know whether anyone knows a clean solution to transfer ownership of a newly created socket to tcp::acceptor::async_accept, which would in turn transfer this ownership to the accept handler function. This isn't an incoherent desire, mind you, since the handler...

How can I return a copy of a vector containing elements not in a set?

Suppose I have the following two data structures: std::vector<int> all_items; std::set<int> bad_items; The all_items vector contains all known items and the bad_items vector contains a list of bad items. These two data structures are populated entirely independent of one another. What's the proper way to write a method that will retu...

min and perfect forwarding

The min algorithm is normally expressed like this: template <typename T> const T& min(const T& x, const T& y) { return y < x ? y : x; } However, this does not allow constructs of the form min(a, b) = 0. You can achieve that with an additional overload: template <typename T> T& min(T& x, T& y) { return y < x ? y : x; } What ...

decltype and parenthesis

I don't understand the last line of the example on page 148 of the FCD (§7.6.1.2/4): const int&& foo(); int i; struct A { double x; }; const A* a = new A(); decltype(foo()) x1 = i; // type is const int&& decltype(i) x2; // type is int decltype(a->x) x3; // type is double decltype((a->x)) x4 = x3; // type is co...

Difference between Scala trait and C++ concepts

What is the difference between Scala traits Haskell type class and C++0x Concepts? ...