From a11636fd41f1e3e22fca2ee1c1e9523ff42ef258 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 23 Jul 2016 17:04:48 +0900 Subject: [PATCH 1/3] Fix documents and tests about include header. --- include/boost/phoenix/config.hpp | 9 ++++--- .../detail/std_unordered_set_or_map_fwd.hpp | 4 ++-- test/algorithm/querying.cpp | 9 +------ test/algorithm/querying_find.cpp | 28 +++++----------------- test/algorithm/querying_find2.cpp | 5 ---- 5 files changed, 13 insertions(+), 42 deletions(-) diff --git a/include/boost/phoenix/config.hpp b/include/boost/phoenix/config.hpp index 9f2138c8..78f724a2 100644 --- a/include/boost/phoenix/config.hpp +++ b/include/boost/phoenix/config.hpp @@ -2,6 +2,7 @@ Copyright (c) 2001-2010 Joel de Guzman Copyright (c) 2010 Eric Niebler Copyright (c) 2014-2015 John Fletcher + Copyright (c) 2016 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -27,15 +28,13 @@ // #endif // // #ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP -// #define BOOST_PHOENIX_UNORDERED_SET_HEADER -// #define BOOST_PHOENIX_UNORDERED_MAP_HEADER +// #include BOOST_PHOENIX_UNORDERED_SET_HEADER +// #include BOOST_PHOENIX_UNORDERED_MAP_HEADER // #endif // // The client code can then chose the implementation provided. // See the example in test/stl/querying_find2.cpp -// -////////////////////////////////////////////////////////////////////////// -// + // There is no specific thing in Boost Config for libc++ #ifdef _LIBCPP_VERSION #define BOOST_PHOENIX_USING_LIBCPP diff --git a/include/boost/phoenix/stl/algorithm/detail/std_unordered_set_or_map_fwd.hpp b/include/boost/phoenix/stl/algorithm/detail/std_unordered_set_or_map_fwd.hpp index 251309a4..d3cc2c4d 100644 --- a/include/boost/phoenix/stl/algorithm/detail/std_unordered_set_or_map_fwd.hpp +++ b/include/boost/phoenix/stl/algorithm/detail/std_unordered_set_or_map_fwd.hpp @@ -22,8 +22,8 @@ #ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP #ifdef BOOST_PHOENIX_USING_LIBCPP // Advance declaration not working for libc++ -#include -#include +#include BOOST_PHOENIX_UNORDERED_SET_HEADER +#include BOOST_PHOENIX_UNORDERED_MAP_HEADER #else diff --git a/test/algorithm/querying.cpp b/test/algorithm/querying.cpp index 2ab97c63..fd9b9124 100644 --- a/test/algorithm/querying.cpp +++ b/test/algorithm/querying.cpp @@ -15,17 +15,10 @@ #include -#ifdef BOOST_HAS_HASH +#ifdef BOOST_PHOENIX_HAS_HASH #define _GLIBCXX_PERMIT_BACKWARD_HASH #include BOOST_HASH_SET_HEADER #include BOOST_HASH_MAP_HEADER -#define BOOST_PHOENIX_HAS_HASH -#define BOOST_PHOENIX_HASH_NAMESPACE BOOST_STD_EXTENSION_NAMESPACE -#elif defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB < 610) -#include -#include -#define BOOST_PHOENIX_HAS_HASH -#define BOOST_PHOENIX_HASH_NAMESPACE stdext #endif #include diff --git a/test/algorithm/querying_find.cpp b/test/algorithm/querying_find.cpp index 976a1070..2806627c 100644 --- a/test/algorithm/querying_find.cpp +++ b/test/algorithm/querying_find.cpp @@ -15,29 +15,13 @@ #include -#if defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB < 610) -#include -#include -#define BOOST_PHOENIX_HAS_HASH -#define BOOST_PHOENIX_HASH_NAMESPACE stdext -#else -#if (defined (BOOST_NO_CXX11_HDR_UNORDERED_MAP) || \ - defined (BOOST_NO_CXX11_HDR_UNORDERED_SET) ) -#ifdef BOOST_HAS_HASH -// This does not work for Clang when using stdlib from gcc 4.9 -// as Clang thinks it is gcc 4.2.1 -//#ifndef BOOST_COMP_CLANG +#ifdef BOOST_PHOENIX_HAS_HASH #define _GLIBCXX_PERMIT_BACKWARD_HASH -#include BOOST_HASH_SET_HEADER -#include BOOST_HASH_MAP_HEADER -#define BOOST_PHOENIX_HAS_HASH -#define BOOST_PHOENIX_HASH_NAMESPACE BOOST_STD_EXTENSION_NAMESPACE -#endif -#else -#define BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP -#include -#include -#endif +#include BOOST_PHOENIX_HASH_SET_HEADER +#include BOOST_PHOENIX_HASH_MAP_HEADER +#elif defined BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP +#include BOOST_PHOENIX_UNORDERED_SET_HEADER +#include BOOST_PHOENIX_UNORDERED_MAP_HEADER #endif #include diff --git a/test/algorithm/querying_find2.cpp b/test/algorithm/querying_find2.cpp index f1ee475f..e8c9709e 100644 --- a/test/algorithm/querying_find2.cpp +++ b/test/algorithm/querying_find2.cpp @@ -22,11 +22,6 @@ #ifdef BOOST_PHOENIX_HAS_HASH #include BOOST_PHOENIX_HASH_SET_HEADER #include BOOST_PHOENIX_HASH_MAP_HEADER -#elif defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB < 610) -#include -#include -#define BOOST_PHOENIX_HAS_HASH -#define BOOST_PHOENIX_HASH_NAMESPACE stdext #elif defined BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP #include BOOST_PHOENIX_UNORDERED_SET_HEADER #include BOOST_PHOENIX_UNORDERED_MAP_HEADER From 7c699c56e9bab8d21687395c33be1636024b546b Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 23 Jul 2016 17:46:28 +0900 Subject: [PATCH 2/3] Don't undefine Boost.Config's feature macro. --- include/boost/phoenix/config.hpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/include/boost/phoenix/config.hpp b/include/boost/phoenix/config.hpp index 78f724a2..e873e0a0 100644 --- a/include/boost/phoenix/config.hpp +++ b/include/boost/phoenix/config.hpp @@ -38,38 +38,33 @@ // There is no specific thing in Boost Config for libc++ #ifdef _LIBCPP_VERSION #define BOOST_PHOENIX_USING_LIBCPP -// This may not be true for some very old version of libc++ -// Current libc++ supports unordered_set and unordered_map without C++11. -#undef BOOST_NO_CXX11_HDR_UNORDERED_MAP -#undef BOOST_NO_CXX11_HDR_UNORDERED_SET #endif -#if (!defined(BOOST_PHOENIX_USING_LIBCPP) \ - && (defined (BOOST_NO_CXX11_HDR_UNORDERED_MAP) || \ - defined (BOOST_NO_CXX11_HDR_UNORDERED_SET) ) ) +// This may not be true for some very old version of libc++ +// Current libc++ supports unordered_set and unordered_map without C++11. +#if defined(BOOST_PHOENIX_USING_LIBCPP) \ + && !(defined(BOOST_NO_CXX11_HDR_UNORDERED_MAP) || defined(BOOST_NO_CXX11_HDR_UNORDERED_SET)) +// This is either libc++ or C++11 or later +#define BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP +#define BOOST_PHOENIX_UNORDERED_SET_HEADER +#define BOOST_PHOENIX_UNORDERED_MAP_HEADER +#define BOOST_PHOENIX_UNORDERED_NAMESPACE std +#else #ifdef BOOST_HAS_HASH // This is to sort out case of Clang when using stdlib from gcc // as Clang thinks it is gcc 4.2.1 // This prevents the failure to include a header with a warning. #define _GLIBCXX_PERMIT_BACKWARD_HASH -#define BOOST_PHOENIX_PERMIT_BACKWARD_HASH #define BOOST_PHOENIX_HASH_SET_HEADER BOOST_HASH_SET_HEADER #define BOOST_PHOENIX_HASH_MAP_HEADER BOOST_HASH_MAP_HEADER #define BOOST_PHOENIX_HAS_HASH #define BOOST_PHOENIX_HASH_NAMESPACE BOOST_STD_EXTENSION_NAMESPACE - #elif defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB < 610) #define BOOST_PHOENIX_HASH_SET_HEADER #define BOOST_PHOENIX_HASH_MAP_HEADER #define BOOST_PHOENIX_HAS_HASH #define BOOST_PHOENIX_HASH_NAMESPACE stdext #endif -#else -// This is either libc++ or C++11 or later -#define BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP -#define BOOST_PHOENIX_UNORDERED_SET_HEADER -#define BOOST_PHOENIX_UNORDERED_MAP_HEADER -#define BOOST_PHOENIX_UNORDERED_NAMESPACE std #endif #endif From b82906369edcd1f34f8d528b2f7ad6af4fd88ad6 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 23 Jul 2016 17:55:29 +0900 Subject: [PATCH 3/3] Detect container availability independently. --- include/boost/phoenix/config.hpp | 6 +++--- test/algorithm/querying_find.cpp | 8 +++++--- test/algorithm/querying_find2.cpp | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/boost/phoenix/config.hpp b/include/boost/phoenix/config.hpp index e873e0a0..ad81c019 100644 --- a/include/boost/phoenix/config.hpp +++ b/include/boost/phoenix/config.hpp @@ -49,8 +49,9 @@ #define BOOST_PHOENIX_UNORDERED_SET_HEADER #define BOOST_PHOENIX_UNORDERED_MAP_HEADER #define BOOST_PHOENIX_UNORDERED_NAMESPACE std -#else -#ifdef BOOST_HAS_HASH +#endif + +#if defined(BOOST_HAS_HASH) // This is to sort out case of Clang when using stdlib from gcc // as Clang thinks it is gcc 4.2.1 // This prevents the failure to include a header with a warning. @@ -65,6 +66,5 @@ #define BOOST_PHOENIX_HAS_HASH #define BOOST_PHOENIX_HASH_NAMESPACE stdext #endif -#endif #endif diff --git a/test/algorithm/querying_find.cpp b/test/algorithm/querying_find.cpp index 2806627c..99707aa2 100644 --- a/test/algorithm/querying_find.cpp +++ b/test/algorithm/querying_find.cpp @@ -16,10 +16,10 @@ #include #ifdef BOOST_PHOENIX_HAS_HASH -#define _GLIBCXX_PERMIT_BACKWARD_HASH #include BOOST_PHOENIX_HASH_SET_HEADER #include BOOST_PHOENIX_HASH_MAP_HEADER -#elif defined BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP +#endif +#ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP #include BOOST_PHOENIX_UNORDERED_SET_HEADER #include BOOST_PHOENIX_UNORDERED_MAP_HEADER #endif @@ -73,7 +73,9 @@ namespace convert_to_container >(); BOOST_TEST(boost::phoenix::find(arg1, 2)(hm) == hm.find(2)); -#elif defined BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP +#endif +#ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP + std::unordered_set us(array, array + 3); BOOST_TEST(boost::phoenix::find(arg1, 2)(us) == us.find(2)); diff --git a/test/algorithm/querying_find2.cpp b/test/algorithm/querying_find2.cpp index e8c9709e..9f6b8c54 100644 --- a/test/algorithm/querying_find2.cpp +++ b/test/algorithm/querying_find2.cpp @@ -22,12 +22,12 @@ #ifdef BOOST_PHOENIX_HAS_HASH #include BOOST_PHOENIX_HASH_SET_HEADER #include BOOST_PHOENIX_HASH_MAP_HEADER -#elif defined BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP +#endif +#ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP #include BOOST_PHOENIX_UNORDERED_SET_HEADER #include BOOST_PHOENIX_UNORDERED_MAP_HEADER #endif - namespace { struct even @@ -71,7 +71,8 @@ namespace convert_to_container >(); BOOST_TEST(boost::phoenix::find(arg1, 2)(hm) == hm.find(2)); -#elif defined BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP +#endif +#ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP std::unordered_set us(array, array + 3); BOOST_TEST(boost::phoenix::find(arg1, 2)(us) == us.find(2));