diff options
author | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
---|---|---|
committer | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
commit | 222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch) | |
tree | 7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp | |
parent | 3d206f03985b50beacae843d880bccdc91a9f424 (diff) |
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp')
-rw-r--r-- | clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp new file mode 100644 index 0000000..fec8060 --- /dev/null +++ b/clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp @@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +namespace DeductionForInstantiation { + template<unsigned I, typename ...Types> + struct X { }; + + template<typename ...Types> + void f0(X<sizeof...(Types), Types&...>) { } + + // No explicitly-specified arguments + template void f0(X<0>); + template void f0(X<1, int&>); + template void f0(X<2, int&, short&>); + + // One explicitly-specified argument + template void f0<float>(X<1, float&>); + template void f0<double>(X<1, double&>); + + // Two explicitly-specialized arguments + template void f0<char, unsigned char>(X<2, char&, unsigned char&>); + template void f0<signed char, char>(X<2, signed char&, char&>); + + // FIXME: Extension of explicitly-specified arguments + // template void f0<short, int>(X<3, short&, int&, long&>); +} + +namespace DeductionWithConversion { + template<char...> struct char_values { + static const unsigned value = 0; + }; + + template<int C1, char C3> + struct char_values<C1, 12, C3> { + static const unsigned value = 1; + }; + + int check0[char_values<1, 12, 3>::value == 1? 1 : -1]; + + template<int...> struct int_values { + static const unsigned value = 0; + }; + + template<unsigned char C1, unsigned char C3> + struct int_values<C1, 12, C3> { + static const unsigned value = 1; + }; + + int check1[int_values<256, 12, 3>::value == 0? 1 : -1]; + int check2[int_values<3, 12, 3>::value == 1? 1 : -1]; +} |