diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..22a0c86 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,102 @@ +# Copyright 2016 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) + +language: cpp + +sudo: false + +python: "2.7" + +os: + - linux + - osx + +branches: + only: + - master + - develop + +env: + matrix: + - BOGUS_JOB=true + +addons: + apt: + packages: + - g++-4.9 + - g++-5 + - g++-6 + - clang-3.6 + - clang-3.7 + - clang-3.8 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise + - llvm-toolchain-precise-3.6 + - llvm-toolchain-precise-3.7 + - llvm-toolchain-precise-3.8 + +matrix: + + exclude: + - env: BOGUS_JOB=true + + include: + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++11 + + - os: linux + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++11 + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++11 + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++14 + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++1z + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++11 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++11 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++11 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++14 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++1z + + - os: osx + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11 + + - os: osx + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++14 + +install: + - cd .. + - git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + - cd boost-root + - git submodule update --init --depth 1 tools/build + - git submodule update --init --depth 1 libs/config + - git submodule update --init --depth 1 tools/boostdep + - mkdir libs/mp11 + - cp -r $TRAVIS_BUILD_DIR/* libs/mp11 + - python tools/boostdep/depinst/depinst.py mp11 + - ./bootstrap.sh + - ./b2 headers + +script: + - |- + echo "using $TOOLSET : : $COMPILER : -std=$CXXSTD ;" > ~/user-config.jam + - ./b2 libs/mp11/test toolset=$TOOLSET + +notifications: + email: + on_success: always diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index 7c601b4..76f727e 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -796,8 +796,13 @@ template class L, class... T> struct mp_unique_impl> template using mp_unique = typename detail::mp_unique_impl::type; // mp_all_of +template class P> using mp_all_of = mp_equal_to< mp_count_if, mp_size >; + // mp_none_of +template class P> using mp_none_of = mp_not< mp_count_if >; + // mp_any_of +template class P> using mp_any_of = mp_to_bool< mp_count_if >; } // namespace boost diff --git a/include/boost/mp11/function.hpp b/include/boost/mp11/function.hpp index 68d1494..c78fe29 100644 --- a/include/boost/mp11/function.hpp +++ b/include/boost/mp11/function.hpp @@ -8,11 +8,18 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt +#include +#include + namespace boost { -// mp_plus // mp_not +template using mp_not = mp_bool< !T::value >; + +// mp_equal_to +template using mp_equal_to = mp_bool< T1::value == T2::value >; + // mp_all // mp_and // mp_any diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 76efec9..1457fdf 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -55,6 +55,9 @@ run mp_reverse.cpp : : : $(REQ) ; run mp_fold.cpp : : : $(REQ) ; run mp_reverse_fold.cpp : : : $(REQ) ; run mp_unique.cpp : : : $(REQ) ; +run mp_all_of.cpp : : : $(REQ) ; +run mp_any_of.cpp : : : $(REQ) ; +run mp_none_of.cpp : : : $(REQ) ; # integral run integral.cpp : : : $(REQ) ; diff --git a/test/mp_all_of.cpp b/test/mp_all_of.cpp new file mode 100644 index 0000000..a19b18e --- /dev/null +++ b/test/mp_all_of.cpp @@ -0,0 +1,57 @@ + +// Copyright 2015, 2016 Peter Dimov. +// +// 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 + + +#include +#include +#include +#include +#include +#include +#include + +struct X1 {}; + +int main() +{ + using boost::mp_list; + using boost::mp_all_of; + using boost::mp_true; + using boost::mp_false; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + + using L2 = mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + + using L2 = std::tuple; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + } + + { + using L2 = std::pair; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + } + + return boost::report_errors(); +} diff --git a/test/mp_any_of.cpp b/test/mp_any_of.cpp new file mode 100644 index 0000000..bcf3c19 --- /dev/null +++ b/test/mp_any_of.cpp @@ -0,0 +1,72 @@ + +// Copyright 2015, 2016 Peter Dimov. +// +// 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 + + +#include +#include +#include +#include +#include +#include +#include + +struct X1 {}; + +int main() +{ + using boost::mp_list; + using boost::mp_any_of; + using boost::mp_true; + using boost::mp_false; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + + using L2 = mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + + using L3 = mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + + using L2 = std::tuple; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + + using L3 = std::tuple; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + } + + { + using L2 = std::pair; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + + using L3 = std::pair; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + } + + return boost::report_errors(); +} diff --git a/test/mp_none_of.cpp b/test/mp_none_of.cpp new file mode 100644 index 0000000..1ee4099 --- /dev/null +++ b/test/mp_none_of.cpp @@ -0,0 +1,72 @@ + +// Copyright 2015, 2016 Peter Dimov. +// +// 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 + + +#include +#include +#include +#include +#include +#include +#include + +struct X1 {}; + +int main() +{ + using boost::mp_list; + using boost::mp_none_of; + using boost::mp_true; + using boost::mp_false; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + + using L2 = mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + + using L3 = mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + + using L2 = std::tuple; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + + using L3 = std::tuple; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + } + + { + using L2 = std::pair; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + + using L3 = std::pair; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>)); + } + + return boost::report_errors(); +} diff --git a/test/mp_valid.cpp b/test/mp_valid.cpp index 65ecb9c..ed11ed1 100644 --- a/test/mp_valid.cpp +++ b/test/mp_valid.cpp @@ -48,8 +48,8 @@ int main() #endif BOOST_TEST_TRAIT_FALSE((mp_valid)); -#if !defined( BOOST_GCC ) || !BOOST_WORKAROUND( BOOST_GCC, < 50500 ) - // g++ up to at least 5.4 doesn't like add_reference for some reason or other +#if !defined( BOOST_GCC ) || !BOOST_WORKAROUND( BOOST_GCC, < 70000 ) + // g++ up to at least 6.2 doesn't like add_reference for some reason or other BOOST_TEST_TRAIT_FALSE((mp_valid)); #if !defined( BOOST_MSVC ) || !BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) // msvc-12.0 gives an internal error here diff --git a/test/tuple_for_each.cpp b/test/tuple_for_each.cpp index 325a51e..97de4a7 100644 --- a/test/tuple_for_each.cpp +++ b/test/tuple_for_each.cpp @@ -36,6 +36,9 @@ int main() } } +#if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 8 +#else + { std::tuple, std::unique_ptr, std::unique_ptr> tp{ std::unique_ptr(new int(1)), std::unique_ptr(new int(2)), std::unique_ptr(new int(3)) }; @@ -46,6 +49,8 @@ int main() BOOST_TEST_EQ( s, 123 ); } +#endif + { std::pair tp{ 1, 2 }; diff --git a/test/tuple_for_each_cx.cpp b/test/tuple_for_each_cx.cpp index 220253c..c3accb4 100644 --- a/test/tuple_for_each_cx.cpp +++ b/test/tuple_for_each_cx.cpp @@ -9,7 +9,9 @@ #include #include -#if defined( BOOST_NO_CXX11_CONSTEXPR ) +// Technically std::tuple isn't constexpr enabled in C++11, but it works with libstdc++ + +#if defined( BOOST_NO_CXX11_CONSTEXPR ) || ( defined( _LIBCPP_VERSION ) && __cplusplus < 201400L ) int main() {}