From 9cdc06ce43c15775b7d0509fec9ece2fcf3f365b Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Mon, 8 Jun 2015 15:47:43 -0400 Subject: [PATCH] C++14 readiness --- beast/cxx14/config.h | 36 +++++++++++++++++++-- beast/cxx14/iterator.h | 4 +++ beast/cxx14/tests/integer_sequence.test.cpp | 4 +++ beast/cxx14/utility.h | 4 +++ 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/beast/cxx14/config.h b/beast/cxx14/config.h index cf0541c3b..95ab10ea6 100644 --- a/beast/cxx14/config.h +++ b/beast/cxx14/config.h @@ -20,6 +20,8 @@ #ifndef BEAST_CXX14_CONFIG_H_INCLUDED #define BEAST_CXX14_CONFIG_H_INCLUDED +#include // detect libc++ verison + // Sets C++14 compatibility configuration macros based on build environment // Disables beast c++14 compatibility additions when set to 1 @@ -28,7 +30,7 @@ #ifndef BEAST_NO_CXX14_COMPATIBILITY # ifdef _MSC_VER # define BEAST_NO_CXX14_COMPATIBILITY 1 -# elif defined(__clang__) && defined(_LIBCPP_VERSION) && __cplusplus >= 201305 +# elif defined(__clang__) && defined(_LIBCPP_VERSION) && __cplusplus >= 201402 # define BEAST_NO_CXX14_COMPATIBILITY 1 # else # define BEAST_NO_CXX14_COMPATIBILITY 0 @@ -39,7 +41,7 @@ #ifndef BEAST_NO_CXX14_MAKE_UNIQUE # ifdef _MSC_VER # define BEAST_NO_CXX14_MAKE_UNIQUE 1 -# elif defined(__clang__) && defined(_LIBCPP_VERSION) && __cplusplus >= 201305 +# elif defined(__clang__) && defined(_LIBCPP_VERSION) && __cplusplus >= 201402 # define BEAST_NO_CXX14_MAKE_UNIQUE 1 # else # define BEAST_NO_CXX14_MAKE_UNIQUE 0 @@ -48,7 +50,35 @@ // Disables beast's std::equal safe iterator overloads #ifndef BEAST_NO_CXX14_EQUAL -# define BEAST_NO_CXX14_EQUAL 0 +# ifdef _MSC_VER +# define BEAST_NO_CXX14_EQUAL 0 +# elif defined(__clang__) && defined(_LIBCPP_VERSION) && __cplusplus >= 201402 +# define BEAST_NO_CXX14_EQUAL 1 +# else +# define BEAST_NO_CXX14_EQUAL 0 +# endif +#endif + +// Disables beast's std::integer_sequence +#ifndef BEAST_NO_CXX14_INTEGER_SEQUENCE +# ifdef _MSC_VER +# define BEAST_NO_CXX14_INTEGER_SEQUENCE 0 +# elif defined(__clang__) && defined(_LIBCPP_VERSION) && __cplusplus >= 201402 +# define BEAST_NO_CXX14_INTEGER_SEQUENCE 1 +# else +# define BEAST_NO_CXX14_INTEGER_SEQUENCE 0 +# endif +#endif + +// Disables beast's std::make_reverse_iterator +#ifndef BEAST_NO_CXX14_MAKE_REVERSE_ITERATOR +# ifdef _MSC_VER +# define BEAST_NO_CXX14_MAKE_REVERSE_ITERATOR 0 +# elif defined(__clang__) && defined(_LIBCPP_VERSION) && __cplusplus >= 201402 +# define BEAST_NO_CXX14_MAKE_REVERSE_ITERATOR 1 +# else +# define BEAST_NO_CXX14_MAKE_REVERSE_ITERATOR 0 +# endif #endif #endif diff --git a/beast/cxx14/iterator.h b/beast/cxx14/iterator.h index ee02471cf..dc6741755 100644 --- a/beast/cxx14/iterator.h +++ b/beast/cxx14/iterator.h @@ -24,6 +24,8 @@ #include +#if ! BEAST_NO_CXX14_MAKE_REVERSE_ITERATOR + namespace std { // C++14 implementation of std::make_reverse_iterator to allow creation of a @@ -39,3 +41,5 @@ make_reverse_iterator(Iter i) } #endif + +#endif diff --git a/beast/cxx14/tests/integer_sequence.test.cpp b/beast/cxx14/tests/integer_sequence.test.cpp index 77d4eafdd..a844290c8 100644 --- a/beast/cxx14/tests/integer_sequence.test.cpp +++ b/beast/cxx14/tests/integer_sequence.test.cpp @@ -21,6 +21,8 @@ #include #endif +#if ! BEAST_NO_CXX14_INTEGER_SEQUENCE + #include #include @@ -107,3 +109,5 @@ BEAST_DEFINE_TESTSUITE(integer_sequence,cxx14,beast); } } + +#endif diff --git a/beast/cxx14/utility.h b/beast/cxx14/utility.h index 119be9477..e20d81f55 100644 --- a/beast/cxx14/utility.h +++ b/beast/cxx14/utility.h @@ -26,6 +26,8 @@ #include #include +#if ! BEAST_NO_CXX14_INTEGER_SEQUENCE + namespace std { template @@ -167,3 +169,5 @@ using index_sequence_for = } #endif + +#endif