[Bug libstdc++/70472] is_copy_constructible<vector<unique_ptr<int>>>::value is true
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Apr 18 10:34:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70472
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Askar Safin from comment #0)
> Also, please, make sure that std::is_copy_constructible gives right answers
> for all standard containers. And same for other type_traits
> (move_constructible etc).
That's easy to say but much harder to do.
> I don't know is
> std::is_copy_constructible<std::vector<std::unique_ptr<int>>>::value ==
> false required by the standard. If no, then, please, add this requirement to
> it.
It's not required, and it would be impossible to require it in general. The
problem is that std::vector does have a copy constructor, so the trait value is
true, but instantiating that constructor produces an error when the value_type
is not copyable. The trait is not required to instantiate the constructor (and
doing so would cause other problems).
> I noticed this bug when I tried to implement my own class template similar
> to std::experimental::optional. Compiler give big error message when I
> combine my class with other standard containers. If I add noexcept to my
> move constructor, then the error message disappears.
Types used with std::vector must be nothrow-move-constructible or
copy-constructible. If your type has a throwing move-ctor then vector will try
to copy it, which causes an instantiation error.
> So I think this bug
> somehow related to bug 55043 (bug #55043). If you want, I can describe this
> my class template in detail. Also, this bug is very similar to this comment:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55043#c15 .
It's the same issue as PR 55043, but harder to fix for std::vector because the
relevant constructors are not defined as defaulted.
> I use stdlibc++ shipped with this gcc.
It's libstdc++ not stdlibc++
More information about the Gcc-bugs
mailing list