3
using T = std::vector<std::unique_ptr<int>>;

Why std::is_copy_constructible<T> is true, but following does not compile:

using T = vector<unique_ptr<int>>;

T v1;
T v2 = v1;

(It does not compile in Clang, GCC and MSVC with C++17.)

vladon
  • 8,158
  • 2
  • 47
  • 91
  • Good question, this particular case was asked before. Basically, is_copy_constructible cannot "see" past the existence of the copy constructor that would ultimately fail when invoked. – GManNickG May 31 '20 at 02:30
  • 1
    @GManNickG see also interesting bug causes by this: https://stackoverflow.com/questions/62110426/why-code-with-stdvector-fails-to-compile-but-with-stdunique-ptr-does-not-if – vladon May 31 '20 at 02:32

0 Answers0