[cfe-dev] Issue with map and unordered_map: call to deleted constructor of 'std::pair<const int, int>'

Miles Bader miles at gnu.org
Sat Sep 17 23:02:56 PDT 2011


David Blaikie <dblaikie at gmail.com> writes:
>     simple.cc:6:7: error: call to deleted constructor of 'foo'
> foo g((foo()));          ^ ~~~~~~~    simple.cc:1:8: note: function
> has been explicitly marked deleted here    struct foo {           ^
>
> [g++ compiles this without error]
>
> Clang seems to be implementing not providing implicit move operations by
> implementing them as deleted rather than as not present. This would be
> incorrect & produces the failure above.
>
> The reason this came up in std::pair is a bit weird - it seems libstdc++'s
> std::pair has none of the big 5 (copy ctor, move ctor, copy assignment, move
> assignment, destructor) /except/ the move assignment operator. It does
> however have member function templates that, while not technically copy/move
> construction/assignment, are probably good enough for most cases. (returning
> a temporary probably should invoke the copy ctor of libstdc++'s pair,
> though, since it doesn't have a real move ctor which it should have)
>
> Anyway, the presence of the move assignment operator caused clang to provide
> a deleted move ctor rather than no move ctor at all.

BTW, that error output looks somewhat similar to what I got when trying
to compile a file which included <boost/thread.hpp>; I filed a clang bug
here:

http://llvm.org/bugs/show_bug.cgi?id=10945

Thanks,

-Miles

-- 
White, adj. and n. Black.




More information about the cfe-dev mailing list