浏览代码

Features: Add cxx_default_function_template_args.

Stephen Kelly 11 年之前
父节点
当前提交
adf22f611e

+ 5 - 0
Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst

@@ -52,6 +52,11 @@ The features known to this version of CMake are:
 
   .. _N2343: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf
 
+``cxx_default_function_template_args``
+  Default template arguments for function templates, as defined in DR226_
+
+  .. _DR226: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#226
+
 ``cxx_defaulted_functions``
   Defaulted functions, as defined in N2346_.
 

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

@@ -60,6 +60,7 @@ set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}")
 # TODO: Should be supported by GNU 4.3
 set(GNU43_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
 set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_default_function_template_args "${GNU43_CXX11}")
 set(_cmake_feature_test_cxx_right_angle_brackets "${GNU43_CXX11}")
 set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}")
 set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}")

+ 1 - 0
Source/cmMakefile.cxx

@@ -50,6 +50,7 @@
   F(cxx_constexpr) \
   F(cxx_decltype) \
   F(cxx_decltype_incomplete_return_types) \
+  F(cxx_default_function_template_args) \
   F(cxx_defaulted_functions) \
   F(cxx_delegating_constructors) \
   F(cxx_deleted_functions) \

+ 12 - 0
Tests/CompileFeatures/cxx_default_function_template_args.cpp

@@ -0,0 +1,12 @@
+
+template<typename T = int>
+int someFunc()
+{
+  T t = 0;
+  return t;
+}
+
+void otherFunc()
+{
+  someFunc();
+}