瀏覽代碼

Features: Add cxx_local_type_template_args.

Stephen Kelly 11 年之前
父節點
當前提交
251a1f02a0

+ 5 - 0
Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst

@@ -117,6 +117,11 @@ The features known to this version of CMake are:
 
   .. _N2927: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf
 
+``cxx_local_type_template_args``
+  Local and unnamed types as template arguments, as defined in N2657_.
+
+  .. _N2657: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm
+
 ``cxx_noexcept``
   Exception specifications, as defined in N3050_.
 

+ 1 - 0
Modules/Compiler/GNU-CXX-FeatureTests.cmake

@@ -38,6 +38,7 @@ set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}")
 set(GNU45_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
 set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}")
 set(_cmake_feature_test_cxx_lambdas "${GNU45_CXX11}")
+set(_cmake_feature_test_cxx_local_type_template_args "${GNU45_CXX11}")
 set(_cmake_feature_test_cxx_raw_string_literals "${GNU45_CXX11}")
 # TODO: Should be supported by GNU 4.4
 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")

+ 1 - 0
Source/cmMakefile.cxx

@@ -63,6 +63,7 @@
   F(cxx_inheriting_constructors) \
   F(cxx_inline_namespaces) \
   F(cxx_lambdas) \
+  F(cxx_local_type_template_args) \
   F(cxx_noexcept) \
   F(cxx_nonstatic_member_init) \
   F(cxx_nullptr) \

+ 21 - 0
Tests/CompileFeatures/cxx_local_type_template_args.cpp

@@ -0,0 +1,21 @@
+
+template <typename T>
+class X { };
+template <typename T>
+void f(T t) { }
+struct {} unnamed_obj;
+void f() {
+  struct A { };
+  enum { e1 };
+  typedef struct {} B;
+  B b;
+  X<A> x1;
+  X<A*> x2;
+  X<B> x3;
+  f(e1);
+  f(unnamed_obj);
+  f(b);
+  (void)x1;
+  (void)x2;
+  (void)x3;
+}