diff --git a/cmake/modules/FindCXX11Features.cmake b/cmake/modules/FindCXX11Features.cmake index 810d70d8263c355f4dfe96922e37160f26ce5e35..639cf6383a63087534eb7675aa6c8c6a801b772b 100644 --- a/cmake/modules/FindCXX11Features.cmake +++ b/cmake/modules/FindCXX11Features.cmake @@ -61,7 +61,10 @@ CHECK_CXX_SOURCE_COMPILES(" } " HAVE_NULLPTR ) +include(CheckIncludeFile) +include(CheckIncludeFileCXX) +if(NOT DISABLE_TR1_HEADERS) # array and fill CHECK_CXX_SOURCE_COMPILES(" #include <array> @@ -75,6 +78,36 @@ CHECK_CXX_SOURCE_COMPILES(" " HAVE_ARRAY ) +# Search for some tr1 headers +foreach(_HEADER tuple tr1/tuple type_traits tr1/type_traits) + string(REPLACE "/" "_" _HEADER_VAR ${_HEADER}) + string(TOUPPER ${_HEADER_VAR} _HEADER_VAR ) + check_include_file_cxx(${_HEADER} "HAVE_${_HEADER_VAR}") +endforeach(_HEADER tuple tr1/tuple tr1/type_traits) + +# Check for hash support +check_include_file_cxx("functional" "HAVE_FUNCTIONAL") +if(NOT HAVE_FUNCTIONAL) + check_include_file_cxx("tr1/functional" "HAVE_TR1_FUNCTIONAL") + if(HAVE_TR1_FUNCTIONAL) + set(_functional_header "tr1/functional") + set(_hash_type "std::tr1::hash") + set(_hash_variable "HAVE_TR1_HASH") + endif(HAVE_TR1_FUNCTIONAL) +else() + set(_functional_header "functional") + set(_hash_type "std::hash") + set(_hash_variable "HAVE_STD_HASH") +endif(NOT HAVE_FUNCTIONAL) + +if(_functional_header) + check_cxx_source_compiles(" +#include <${_functional_header}> +int main(void){ + ${_hash_type}<int> hasher; hasher(42); +}" ${_hash_variable}) +endif(_functional_header) + # Check whether if std::integral_constant< T, v > is supported and casts into T CHECK_CXX_SOURCE_COMPILES(" #include <type_traits> @@ -86,6 +119,8 @@ CHECK_CXX_SOURCE_COMPILES(" " HAVE_INTEGRAL_CONSTANT ) +endif(NOT DISABLE_TR1_HEADERS) + # __attribute__((always_inline)) CHECK_CXX_SOURCE_COMPILES(" void __attribute__((always_inline)) foo(void) {} @@ -194,9 +229,9 @@ CHECK_CXX_SOURCE_COMPILES(" } template<typename T1, typename... T> - int add_ints(T1 t1, T... t) + int add_ints(T1 t1, T&&... t) { - return t1 + add_ints(t...); + return t1 + add_ints(std::forward<T>(t)...); } int main(void) @@ -264,36 +299,4 @@ CHECK_CXX_SOURCE_COMPILES(" } " HAVE_RVALUE_REFERENCES ) -include(CheckIncludeFile) -include(CheckIncludeFileCXX) -# Search for some tr1 headers -foreach(_HEADER tuple tr1/tuple type_traits tr1/type_traits) - string(REPLACE "/" "_" _HEADER_VAR ${_HEADER}) - string(TOUPPER ${_HEADER_VAR} _HEADER_VAR ) - check_include_file_cxx(${_HEADER} "HAVE_${_HEADER_VAR}") -endforeach(_HEADER tuple tr1/tuple tr1/type_traits) - -# Check for hash support -check_include_file_cxx("functional" "HAVE_FUNCTIONAL") -if(NOT HAVE_FUNCTIONAL) - check_include_file_cxx("tr1/functional" "HAVE_TR1_FUNCTIONAL") - if(HAVE_TR1_FUNCTIONAL) - set(_functional_header "tr1/functional") - set(_hash_type "std::tr1::hash") - set(_hash_variable "HAVE_TR1_HASH") - endif(HAVE_TR1_FUNCTIONAL) -else() - set(_functional_header "functional") - set(_hash_type "std::hash") - set(_hash_variable "HAVE_STD_HASH") -endif(NOT HAVE_FUNCTIONAL) - -if(_functional_header) - check_cxx_source_compiles(" -#include <${_functional_header}> -int main(void){ - ${_hash_type}<int> hasher; hasher(42); -}" ${_hash_variable}) -endif(_functional_header) - cmake_pop_check_state() diff --git a/m4/cxx0x_variadic.m4 b/m4/cxx0x_variadic.m4 index fadecf0f24e1c6ab158c2af5856a5043035cecc3..ec64f385451fe4bb07862e9bf21b8f9661f9d38e 100644 --- a/m4/cxx0x_variadic.m4 +++ b/m4/cxx0x_variadic.m4 @@ -18,9 +18,9 @@ AC_DEFUN([VARIADIC_TEMPLATES_CHECK],[ } template<typename T1, typename... T> - int add_ints(T1 t1, T... t) + int add_ints(T1 t1, T&&... t) { - return t1 + add_ints(t...); + return t1 + add_ints(std::forward<T>(t)...); }], [ assert( 5 == add_ints(9,3,-5,-2) );