瀏覽代碼

Features: Add cxx_reference_qualified_functions.

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

+ 5 - 0
Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst

@@ -92,6 +92,11 @@ The features known to this version of CMake are:
 
   .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
 
+``cxx_reference_qualified_functions``
+  Reference qualified functions, as defined in N2439_.
+
+  .. _N2439: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm
+
 ``cxx_static_assert``
   Static assert, as defined in N1720_.
 

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

@@ -2,6 +2,9 @@
 # Reference: http://gcc.gnu.org/projects/cxx0x.html
 
 set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408")
+# Introduced in GCC 4.8.1
+set(_cmake_feature_test_cxx_reference_qualified_functions
+  "((__GNUC__ * 100 + __GNUC_MINOR__) > 408 || __GNUC_PATCHLEVEL__ >= 1) && __cplusplus >= 201103L")
 set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L")
 set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}")
 # TODO: Should be supported by GNU 4.7

+ 1 - 0
Source/cmMakefile.cxx

@@ -58,6 +58,7 @@
   F(cxx_override) \
   F(cxx_range_for) \
   F(cxx_raw_string_literals) \
+  F(cxx_reference_qualified_functions) \
   F(cxx_static_assert) \
   F(cxx_strong_enums) \
   F(cxx_trailing_return_types) \

+ 11 - 0
Tests/CompileFeatures/cxx_reference_qualified_functions.cpp

@@ -0,0 +1,11 @@
+
+struct test{
+  void f() & { }
+  void f() && { }
+};
+
+void someFunc(){
+  test t;
+  t.f(); // lvalue
+  test().f(); // rvalue
+}