|
Boost : |
Subject: Re: [boost] [Config] N3276 decltype support on VC++ 11
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2012-09-05 17:51:30
[Michel Morin]
> IIRC, Stephan said that VC++ 11 supports N3276 decltype.
Yep.
[Marshall Clow]
> What we need to do is to figure out the differences between VC10 and VC11 and update the VC config for that.
http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx is the Rosetta Stone - it is accurate to the best of my ability. There is one caveat - rvalue references v2.1 was not completely implemented (it is still tracked by an active bug). This demonstrates what works and what doesn't:
C:\Temp>type meow.cpp
#include <stdio.h>
#include <string>
using namespace std;
void foo(const string&) {
puts("foo(const string&)");
}
void foo(string&&) {
puts("foo(string&&)");
}
#ifdef BAR
void bar(long&&) {
puts("bar(long&&)");
}
#endif
int main() {
foo("meow");
#ifdef BAR
int x = 1729;
bar(x);
#endif
}
C:\Temp>cl /EHsc /nologo /W4 /MTd meow.cpp
meow.cpp
C:\Temp>meow
foo(string&&)
C:\Temp>cl /EHsc /nologo /W4 /MTd /DBAR meow.cpp
meow.cpp
meow.cpp(24) : error C2664: 'bar' : cannot convert parameter 1 from 'int' to 'long &&'
You cannot bind an lvalue to an rvalue reference
C++11 and VC11 agree that foo(string&&) should be selected (the string literal is an lvalue, but the temporary std::string is an rvalue).
C++11 says that bar(long&&) should be invoked (int x is an lvalue, but the temporary long is an rvalue), but VC11 rejects this. That's the remaining bug.
Hope this helps,
STL
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk