From 22dad661fc70f04b12d2cfe471e8f242edac2a4a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 17 Mar 2017 21:52:04 +0200 Subject: [PATCH 1/4] Add more clang to .travis.yml --- .travis.yml | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/.travis.yml b/.travis.yml index a888e72..c6143fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -81,6 +81,25 @@ matrix: sources: - ubuntu-toolchain-r-test + - os: linux + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11 + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=c++11 + addons: + apt: + packages: + - clang-3.5 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.5 + - os: linux env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++11 addons: @@ -131,6 +150,36 @@ matrix: - ubuntu-toolchain-r-test - llvm-toolchain-precise-3.8 + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++11 + addons: + apt: + packages: + - clang-3.9 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.9 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++14 + addons: + apt: + packages: + - clang-3.9 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.9 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++1z + addons: + apt: + packages: + - clang-3.9 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.9 + - os: osx env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11 From 463313629fc8aac7f701a4fb048f4f9ef54f071b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 17 Mar 2017 23:57:06 +0200 Subject: [PATCH 2/4] Try g++-4.9 with the preinstalled clang --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c6143fb..d090677 100644 --- a/.travis.yml +++ b/.travis.yml @@ -86,7 +86,7 @@ matrix: addons: apt: packages: - - g++-6 + - g++-4.9 sources: - ubuntu-toolchain-r-test From d58a1f0f03e2020bd2bbfbc30e22a0f3bb29ab2a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 18 Mar 2017 00:25:48 +0200 Subject: [PATCH 3/4] Drop built-in clang --- .travis.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index d090677..48fc3f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -81,15 +81,6 @@ matrix: sources: - ubuntu-toolchain-r-test - - os: linux - env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11 - addons: - apt: - packages: - - g++-4.9 - sources: - - ubuntu-toolchain-r-test - - os: linux env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=c++11 addons: From e1edd90c217b5e9d018ff403d5a10f79ad2c4e4c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 18 Mar 2017 01:05:54 +0200 Subject: [PATCH 4/4] Fix clang 3.9 -std=c++1z failures --- include/boost/mp11/algorithm.hpp | 42 ++++++++++++++++++++++++++-- include/boost/mp11/detail/config.hpp | 8 ++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index ac19959..8930660 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -498,7 +498,37 @@ namespace detail template struct mp_find_impl; -#if !defined( BOOST_MP11_NO_CONSTEXPR ) +#if defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) + +struct mp_index_holder +{ + std::size_t i_; + bool f_; +}; + +constexpr inline mp_index_holder operator+( mp_index_holder const & v, bool f ) +{ + if( v.f_ ) + { + return v; + } + else if( f ) + { + return { v.i_, true }; + } + else + { + return { v.i_ + 1, false }; + } +} + +template class L, class... T, class V> struct mp_find_impl, V> +{ + static constexpr mp_index_holder _v{ 0, false }; + using type = mp_size_t< (_v + ... + std::is_same::value).i_ >; +}; + +#elif !defined( BOOST_MP11_NO_CONSTEXPR ) template class L, class V> struct mp_find_impl, V> { @@ -558,7 +588,15 @@ namespace detail template class P> struct mp_find_if_impl; -#if !defined( BOOST_MP11_NO_CONSTEXPR ) +#if defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) + +template class L, class... T, template class P> struct mp_find_if_impl, P> +{ + static constexpr mp_index_holder _v{ 0, false }; + using type = mp_size_t< (_v + ... + P::value).i_ >; +}; + +#elif !defined( BOOST_MP11_NO_CONSTEXPR ) template class L, template class P> struct mp_find_if_impl, P> { diff --git a/include/boost/mp11/detail/config.hpp b/include/boost/mp11/detail/config.hpp index 69539aa..3992cdc 100644 --- a/include/boost/mp11/detail/config.hpp +++ b/include/boost/mp11/detail/config.hpp @@ -21,4 +21,12 @@ #endif +#if defined(BOOST_CLANG) && defined(__has_cpp_attribute) +# if __has_cpp_attribute(fallthrough) && __cplusplus >= 201406L // Clang 3.9+ in c++1z mode + +# define BOOST_MP11_HAS_FOLD_EXPRESSIONS + +# endif +#endif + #endif // #ifndef BOOST_MP11_DETAIL_CONFIG_HPP_INCLUDED