瀏覽代碼

Features: Add cxx_generalized_initializers.

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

+ 5 - 0
Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst

@@ -77,6 +77,11 @@ The features known to this version of CMake are:
 
   .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm
 
+``cxx_generalized_initializers``
+  Initializer lists, as defined in N2672_.
+
+  .. _N2672: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm
+
 ``cxx_inheriting_constructors``
   Inheriting constructors, as defined in N2540_.
 

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

@@ -40,6 +40,7 @@ set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
 set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}")
 set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}")
 set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_generalized_initializers "${GNU44_CXX11}")
 set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}")
 set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}")
 set(_cmake_feature_test_cxx_unicode_literals "${GNU44_CXX11}")

+ 1 - 0
Source/cmMakefile.cxx

@@ -55,6 +55,7 @@
   F(cxx_explicit_conversions) \
   F(cxx_extern_templates) \
   F(cxx_final) \
+  F(cxx_generalized_initializers) \
   F(cxx_inheriting_constructors) \
   F(cxx_lambdas) \
   F(cxx_noexcept) \

+ 23 - 0
Tests/CompileFeatures/cxx_generalized_initializers.cpp

@@ -0,0 +1,23 @@
+
+// Dummy implementation. Test only the compiler feature.
+namespace std {
+  typedef decltype(sizeof(int)) size_t;
+  template <class _E>
+  class initializer_list
+  {
+    const _E* __begin_;
+    size_t    __size_;
+
+  };
+}
+
+template <typename T>
+struct A
+{
+  A(std::initializer_list<T>) {}
+};
+
+void someFunc()
+{
+  A<int> as = { 1, 2, 3, 4 };
+}