[cfe-dev] Implicit conversion of enum to int within an initializer list
Ryuta Suzuki
ryuuta at gmail.com
Tue Jul 26 14:33:52 PDT 2011
Oh, I thought it was implemented in clang already.
Thanks for the info, Doug.
Regards,
Ryuta
On Wed, Jul 27, 2011 at 6:26 AM, Douglas Gregor <dgregor at apple.com> wrote:
>
> On Jul 26, 2011, at 2:23 PM, Ryuta Suzuki wrote:
>
> Hi,
>
> I'm curious if the enum values can be put in initializer list of
> st::vector<int>,
>
> #include <vector>
>
> int main()
> {
> enum Type
> {
> None = 0x0,
> A = 0x1,
> B = 0x2,
> C = 0x4
> };
>
> typedef std::vector<int> TypeVector;
> TypeVector types = { Type::A, Type::B, Type::C };
>
> return 0;
> }
>
> g++ can compile it but clang++ can't:
>
> $ g++ -Wall -Wextra -std=c++0x ./classes_vector.cpp
>
> $ clang++ -Wall -Wextra -std=c++0x -stdlib=libc++ ./classes_vector.cpp
> ./classes_vector.cpp:14:14: error: non-aggregate type 'TypeVector' (aka
> 'vector<int>') cannot be initialized with an initializer list
> TypeVector types = { Type::A, Type::B, Type::C };
> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
>
> Could this be clang bug?
>
>
> It's not a bug; C++0x generalized initializer lists haven't been
> implemented in Clang yet.
>
> - Doug
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110727/e5c86f98/attachment.html>
More information about the cfe-dev
mailing list