Does Visual Studio 2012 do this correctly? std::move

574 views Asked by At

A question I recently tried to answer seemed to be an error in vs2012's c++11 support.

Specifically, It failed to compile std::map with a non copy-constructible value_type, despite only std::move being used to insert into the map. Either the wrong insert overload is chosen, or the compiler doesn't consider the alternative.

Basically, I wan't to know if the following code:

#include <iostream>
#include <memory>
#include <utility>
#include <type_traits>

class Foo {
};

using namespace std;

int main() {
    cout << is_constructible<pair<const int,unique_ptr<Foo> >, pair<const int,unique_ptr<Foo> >& >::value << '\n';
    cout << is_constructible<pair<const int,unique_ptr<Foo> >, pair<const int,unique_ptr<Foo> >&& >::value << '\n';
}

gives the output 01.

1

There are 1 answers

5
Shafik Yaghmour On BEST ANSWER

Visual Studio outputs(see it live):

1
1

Which is clearly wrong and both gcc and clang give the expected results. This bug and the original issue you are seeing may be related to these two accepted bug reports. The incorrect results from is_constructible may actually be unrelated to the original bug: