(no subject)

Compiling the following code:
#include
#include
#include <initializer_list>

struct C {
std::vector< std::unique_ptr > vec;

C(std::initializer_list< std::unique_ptr > init)
: vec(std::make_move_iterator(init.begin()),
std::make_move_iterator(init.end()))
{}
};

with clang version 3.6.0 (trunk 222993) (llvm/trunk 222992)
resulted in a perplexing message:

In file included from wtf.cc:1:
In file included from /usr/local/bin/…/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/…/…/…/gcc/x86_64-unknown-linux-gnu/4.9.0/include/c++/memory:62:
In file included from /usr/local/bin/…/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/…/…/…/gcc/x86_64-unknown-linux-gnu/4.9.0/include/c++/bits/stl_algobase.h:67:
/usr/local/bin/…/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/…/…/…/gcc/x86_64-unknown-linux-gnu/4.9.0/include/c++/bits/stl_iterator.h:995:16: error: binding of reference to type ‘unique_ptr<[2 * …]>’ to a value

of type ‘unique_ptr<[2 * …]>’ drops qualifiers
{ return std::move(*_M_current); }
^~~~~~~~~~~~~~~~~~~~~~

I can see no qualifiers to be dropped
(although std::initializer_list gives only const access to its contents)

GCC’s error message sheds a bit more light on what’s wrong:

/usr/include/c++/4.8/bits/stl_iterator.h:963:37: error: invalid initialization of reference of type ‘std::move_iterator<const std::unique_ptr>::reference {aka std::unique_ptr&&}’ from expression of type ‘std::remove_reference<const std::unique_ptr&>::type {aka const std::unique_ptr}’
{ return std::move(
_M_current); }
^

Note the presence of ‘const’ in the GCC error message, as opposed to clang (which makes no mention of const).

Csaba

(please excuse ghastly formatting by Gmail)