From 43144e72b5197c2e17a5586a59d41afe177d5055 Mon Sep 17 00:00:00 2001 From: Sebastian Redl Date: Tue, 17 Jan 2012 22:49:58 +0000 Subject: Template argument deduction for std::initializer_list arguments from initializer lists. llvm-svn: 148352 --- .../cxx0x-initializer-stdinitializerlist.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp') diff --git a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp index 87e7e8462ba..a08a04806ca 100644 --- a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp +++ b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp @@ -32,6 +32,11 @@ namespace std { }; } +template +struct same_type { static const bool value = false; }; +template +struct same_type { static const bool value = true; }; + struct one { char c[1]; }; struct two { char c[2]; }; @@ -87,3 +92,20 @@ void overloaded_call() { // But here, user-defined is worst in both cases. ov2({1, 2, D()}); // expected-error {{ambiguous}} } + +template +T deduce(std::initializer_list); // expected-note {{conflicting types for parameter 'T' ('int' vs. 'double')}} +template +T deduce_ref(const std::initializer_list&); // expected-note {{conflicting types for parameter 'T' ('int' vs. 'double')}} + +void argument_deduction() { + static_assert(same_type::value, "bad deduction"); + static_assert(same_type::value, "bad deduction"); + + deduce({1, 2.0}); // expected-error {{no matching function}} + + static_assert(same_type::value, "bad deduction"); + static_assert(same_type::value, "bad deduction"); + + deduce_ref({1, 2.0}); // expected-error {{no matching function}} +} -- cgit v1.2.3