0

A vector of unique_ptrs is obviously not copyable as proved by the code snippet below. The corresponding trait of is_copy_constructible returns true dispite of this. Why is that?

#include <memory>
#include <vector>

// This static assert passes, which is surprising
static_assert(std::is_copy_constructible_v<std::vector<std::unique_ptr<int>>>);

std::vector<std::unique_ptr<int>>
test(const std::vector<std::unique_ptr<int>>& original)
{
    std::vector<std::unique_ptr<int>> copy /* = original */;
    // commented-out part does not compile, as expected
    return copy;
}
palotasb
  • 4,108
  • 3
  • 24
  • 32

0 Answers0