Re: Visual Studio C++ 2012 is adding variadic templates
On 6 Nov 2012 09:57:48 GMT
Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
On Tue, 2012-11-06, Melzzzzz wrote:
On Mon, 05 Nov 2012 16:14:32 -0600
Lynn McGuire <lmc@winsim.com> wrote:
Visual Studio C++ 2012 is adding variadic templates
and initializer lists to Visual Studio 2012.
http://arstechnica.com/information-technology/2012/11/c-coming-back-into-the-mainstream-with-more-specs-more-often/
Looks like MS is trying to stay up to speed.
Lynn
Great, but way lags behind g++. All in all we can get g++ from svn
repository and get new features immediately...
Yes, but if you're writing software which is supposed to work
reliably, that's really of little use. Although it allow you to toy
with and learn new features early.
/Jorgen
Well this is short introspection of new features from gcc 4.8 ;)
It is pretty reliable, I think...
#include <iostream>
#include <mutex>
#include <thread>
class A{
public:
A(int i):i(i){}
alignas(double) int i;
};
class alignas(16) B:public A{
public:
B():B(42){}
using A::A;
};
void f(int i)
{
static thread_local B b(i);
static std::mutex m;
std::lock_guard<std::mutex> g(m);
std::cout<<b.i<<'\n';
}
int main()
{
std::thread a(f,1);
std::thread b(f,2);
a.join();
b.join();
}
bmaxa@maxa:~/examples$ g++-trunk -std=c++11 -pthread inherit.cpp -o inherit
bmaxa@maxa:~/examples$ ./inherit
1
2