diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2012-01-17 22:50:08 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2012-01-17 22:50:08 +0000 |
commit | 62b7cfb73e202051e7ab0dad42ba213acd0dec7e (patch) | |
tree | 538eaf3463957424716e658e8181dfea311ec2e8 /test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp | |
parent | 84760e3a5d885ab19b5d11aafe78dfdfe2911e3a (diff) |
Auto deduction support for std::initializer_list, including for-range support. This means you can now write:
for (int i : {1, 4, 512, 23, 251}) {}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148353 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp')
-rw-r--r-- | test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp index a08a04806c..47ceaf0b83 100644 --- a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp +++ b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp @@ -109,3 +109,11 @@ void argument_deduction() { deduce_ref({1, 2.0}); // expected-error {{no matching function}} } + +void auto_deduction() { + auto l = {1, 2, 3, 4}; + static_assert(same_type<decltype(l), std::initializer_list<int>>::value, ""); + auto bl = {1, 2.0}; // expected-error {{cannot deduce}} + + for (int i : {1, 2, 3, 4}) {} +} |