├── meta └── libraries.json ├── test ├── transform_test.hpp ├── join_test.hpp ├── zip_with_index_test.hpp ├── product_test.hpp ├── partition_test.hpp ├── take_test.hpp ├── erase_test.hpp ├── try_test.hpp ├── count_if_test.hpp ├── test.cpp ├── test_util.hpp ├── fold_right_test.hpp ├── reverse_test.hpp ├── contains_test.hpp ├── logic_test.hpp ├── find_if_test.hpp ├── fold_left_test.hpp ├── filter_test.hpp ├── tee_test.hpp └── sort_test.hpp ├── .gitignore ├── include └── boost │ ├── tmp │ ├── detail │ │ ├── capabilities.hpp │ │ ├── fusion_execute.hpp │ │ ├── fusion_rebind.hpp │ │ ├── dispatch.hpp │ │ └── expression.hpp │ ├── sequence │ │ ├── zip.hpp │ │ ├── swap.hpp │ │ ├── size.hpp │ │ ├── push_back.hpp │ │ ├── push_front.hpp │ │ ├── take.hpp │ │ ├── pop_front.hpp │ │ ├── erase.hpp │ │ ├── insert.hpp │ │ ├── container.hpp │ │ ├── unpack.hpp │ │ ├── zip_with_index.hpp │ │ ├── each.hpp │ │ ├── make_sequence.hpp │ │ ├── index.hpp │ │ ├── join.hpp │ │ ├── drop.hpp │ │ ├── rotate.hpp │ │ ├── tee.hpp │ │ └── reverse.hpp │ ├── algorithm │ │ ├── contains.hpp │ │ ├── partition.hpp │ │ ├── remove_if.hpp │ │ ├── replace_if.hpp │ │ ├── count_if.hpp │ │ ├── transform.hpp │ │ ├── product.hpp │ │ ├── filter.hpp │ │ ├── find_if.hpp │ │ ├── fold_right.hpp │ │ ├── sort.hpp │ │ └── fold_left.hpp │ ├── always.hpp │ ├── identity.hpp │ ├── vocabulary.hpp │ ├── comparison.hpp │ ├── try.hpp │ ├── lift.hpp │ ├── fusion │ │ ├── contains.hpp │ │ ├── find_if.hpp │ │ └── filter.hpp │ ├── fusion.hpp │ ├── if.hpp │ ├── call.hpp │ ├── pack.hpp │ └── logic.hpp │ └── tmp.hpp ├── .travis.yml ├── .clang-format ├── CMakeLists.txt └── README.md /meta/libraries.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "mixin", 3 | "name": "Mixin", 4 | "authors": [ 5 | "Odin Holmes" 6 | ], 7 | "maintainers": [ 8 | "Odin Holmes " 9 | ], 10 | "description": "A C++11 library for generic compositional component design.", 11 | "category": [ 12 | "Metaprogramming" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /test/transform_test.hpp: -------------------------------------------------------------------------------- 1 | #include "test_util.hpp" 2 | 3 | namespace transform_test { 4 | int run() { 5 | using rhs = make_sequence_>; 6 | using lhs = make_sequence_; 7 | call_>, extent>{} = 8 | call_>, extent>{}; 9 | 10 | return 0; 11 | } 12 | } // namespace transform_test 13 | -------------------------------------------------------------------------------- /test/join_test.hpp: -------------------------------------------------------------------------------- 1 | #include "test_util.hpp" 2 | #include "../include/boost/tmp/sequence/join.hpp" 3 | 4 | namespace join_test { 5 | int run() { 6 | using make_listified_sequence = make_sequence_, join_<>>>; 7 | call_>>, extent>{} = 8 | call_>, extent>{}; 9 | 10 | return 0; 11 | } 12 | } // namespace join_test -------------------------------------------------------------------------------- /test/zip_with_index_test.hpp: -------------------------------------------------------------------------------- 1 | #include "test_util.hpp" 2 | 3 | namespace zip_with_index_test { 4 | template 5 | using doubleify = list_; 6 | 7 | int run() { 8 | using lhs = make_sequence_>; 9 | using rhs = make_sequence_>; 10 | call_>, extent>{} = 11 | call_>, extent>{}; 12 | 13 | return 0; 14 | } 15 | } // namespace zip_with_index_test 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Directories 35 | build/ 36 | cmake-build-debug/ 37 | .idea/ 38 | .vscode/ -------------------------------------------------------------------------------- /include/boost/tmp/detail/capabilities.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_CAPABILITIES_HPP_INCLUDED 2 | #define BOOST_TMP_CAPABILITIES_HPP_INCLUDED 3 | 4 | #if __clang_major__ == 3 5 | #define BOOST_TMP_CLANG_ARITY_BUG 6 | #endif 7 | #if __cplusplus >= 201103L 8 | #if __cplusplus >= 201402L 9 | #define BOOST_TMP_CPP14 10 | #define BOOST_TMP_COMPLEX_CONSTEXPR constexpr 11 | #else 12 | #define BOOST_TMP_COMPLEX_CONSTEXPR 13 | #endif 14 | #else 15 | #error "__cplusplus must be > 201103L (the value of C++11)" 16 | #endif 17 | 18 | #endif -------------------------------------------------------------------------------- /test/product_test.hpp: -------------------------------------------------------------------------------- 1 | #include "test_util.hpp" 2 | #include "../include/boost/tmp/algorithm/product.hpp" 3 | 4 | namespace product_test { 5 | template 6 | struct x { 7 | static constexpr int value = I; 8 | }; 9 | 10 | using xl0 = list_, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>, x<8>, x<9>, x<10>>; 11 | using xr0 = list_, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>, x<8>, x<9>, x<10>>; 12 | 13 | using result0 = call_, xl0, xr0>; 14 | int run() { 15 | 16 | return 0; 17 | } 18 | } // namespace product_test -------------------------------------------------------------------------------- /include/boost/tmp/detail/fusion_execute.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_FUSION_EXECUTE_HPP_INCLUDED 2 | #define BOOST_TMP_FUSION_EXECUTE_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | #include "../vocabulary.hpp" 11 | 12 | namespace boost { 13 | namespace tmp { 14 | namespace fusion {} 15 | } // namespace tmp 16 | } // namespace boost 17 | 18 | #endif -------------------------------------------------------------------------------- /test/partition_test.hpp: -------------------------------------------------------------------------------- 1 | #include "test_util.hpp" 2 | #include "../include/boost/tmp/algorithm/partition.hpp" 3 | 4 | namespace partition_test { 5 | template 6 | struct x { 7 | static constexpr int value = I; 8 | }; 9 | 10 | using xs0 = list_, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>, x<8>, x<9>, x<10>>; 11 | 12 | template 13 | using more_than_5 = bool_<(T::value > 5)>; 14 | 15 | using result0 = call_>>, xs0>; 16 | int run() { 17 | 18 | return 0; 19 | } 20 | } // namespace partition_test -------------------------------------------------------------------------------- /test/take_test.hpp: -------------------------------------------------------------------------------- 1 | #include "test_util.hpp" 2 | #include "../include/boost/tmp/sequence/take.hpp" 3 | #include "../include/boost/tmp/vocabulary.hpp" 4 | namespace take_test { 5 | template 6 | struct x; 7 | 8 | using xs0 = list_, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>, x<8>, x<9>, x<10>>; 9 | 10 | using result0 = call_>>, xs0>; 11 | using result1 = call_>>, xs0>; 12 | using result2 = call_>>, xs0>; 13 | 14 | int run() { 15 | 16 | return 0; 17 | } 18 | } // namespace take_test -------------------------------------------------------------------------------- /test/erase_test.hpp: -------------------------------------------------------------------------------- 1 | #include "test_util.hpp" 2 | #include "../include/boost/tmp/sequence/erase.hpp" 3 | #include "../include/boost/tmp/vocabulary.hpp" 4 | namespace erase_test { 5 | template 6 | struct x; 7 | 8 | using xs0 = list_, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>, x<8>, x<9>, x<10>>; 9 | 10 | using result0 = call_>>, xs0>; 11 | using result1 = call_>>, xs0>; 12 | using result2 = call_>>, xs0>; 13 | 14 | int run() { 15 | 16 | return 0; 17 | } 18 | } // namespace erase_test -------------------------------------------------------------------------------- /test/try_test.hpp: -------------------------------------------------------------------------------- 1 | #include "test_util.hpp" 2 | #include "../include/boost/tmp/try.hpp" 3 | 4 | namespace try_test { 5 | template 6 | using call_type = typename T::type; 7 | 8 | struct has_type { 9 | using type = int; 10 | }; 11 | int run() { 12 | nothing_{} = call_, int>{}; // should SFINAE, int has no ::type 13 | list_{} = list_, has_type>>{}; // should not SFINAE 14 | list_{} = call_, has_type>{}; // test the continuation 15 | 16 | return 0; 17 | } 18 | } // namespace try_test 19 | -------------------------------------------------------------------------------- /include/boost/tmp/sequence/zip.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_ZIP_HPP_INCLUDED 2 | #define BOOST_TMP_ZIP_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include 12 | #include "../call.hpp" 13 | #include "../vocabulary.hpp" 14 | 15 | namespace boost { 16 | namespace tmp { 17 | template 18 | struct zip_ {}; 19 | namespace detail { 20 | // TODO add impl 21 | } 22 | } // namespace tmp 23 | } // namespace boost 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /test/count_if_test.hpp: -------------------------------------------------------------------------------- 1 | #include "test_util.hpp" 2 | #include "../include/boost/tmp/algorithm/count_if.hpp" 3 | 4 | namespace count_if_test { 5 | template 6 | using divide_by_two_celing = int_<((T::value >> 1) + (T::value & 1))>; 7 | template 8 | using multiply_by_2 = uint_<(T::value << 1)>; 9 | 10 | template 11 | using is_even = bool_<(T::value % 2 == 0)>; 12 | int run() { 13 | 14 | uint_<0>{} = call_>, int_<1>>{}; 15 | uint_<1>{} = call_>, int_<2>>{}; 16 | uint_<0>{} = call_>, int_<1>, int_<1>, int_<1>>{}; 17 | 18 | return 0; 19 | } 20 | } // namespace count_if_test -------------------------------------------------------------------------------- /test/test.cpp: -------------------------------------------------------------------------------- 1 | #include "contains_test.hpp" 2 | #include "count_if_test.hpp" 3 | #include "erase_test.hpp" 4 | #include "filter_test.hpp" 5 | #include "tee_test.hpp" 6 | #include "find_if_test.hpp" 7 | #include "fold_left_test.hpp" 8 | #include "fold_right_test.hpp" 9 | #include "join_test.hpp" 10 | #include "logic_test.hpp" 11 | #include "partition_test.hpp" 12 | #include "product_test.hpp" 13 | #include "reverse_test.hpp" 14 | #include "sort_test.hpp" 15 | #include "take_test.hpp" 16 | #include "transform_test.hpp" 17 | #include "try_test.hpp" 18 | #include "zip_with_index_test.hpp" 19 | 20 | int main() { 21 | return join_test::run() || transform_test::run() || fold_left_test::run() || 22 | zip_with_index_test::run(); 23 | } 24 | -------------------------------------------------------------------------------- /test/test_util.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_TEST_UTIL_HPP_INCLUDED 2 | #define BOOST_TMP_TEST_UTIL_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "../include/boost/tmp/call.hpp" 12 | #include "../include/boost/tmp/sequence/make_sequence.hpp" 13 | #include "../include/boost/tmp/sequence/push_front.hpp" 14 | #include "../include/boost/tmp/sequence/tee.hpp" 15 | 16 | using namespace boost::tmp; 17 | template 18 | using make_algo = tee_, identity_, call_f_<>>; 19 | 20 | using extent = uint_<50>; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/boost/tmp/algorithm/contains.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_CONTAINS_HPP_INCLUDED 2 | #define BOOST_TMP_CONTAINS_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "../identity.hpp" 12 | #include "../logic.hpp" 13 | 14 | namespace boost { 15 | namespace tmp { 16 | template 17 | struct contains_; 18 | 19 | namespace detail { 20 | template 21 | struct dispatch> : dispatch, C>> {}; 22 | } // namespace detail 23 | } // namespace tmp 24 | } // namespace boost 25 | 26 | #endif -------------------------------------------------------------------------------- /include/boost/tmp/sequence/swap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_SWAP_HPP_INCLUDED 2 | #define BOOST_TMP_SWAP_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "../identity.hpp" 12 | #include "../vocabulary.hpp" 13 | namespace boost { 14 | namespace tmp { 15 | template 16 | struct swap_ {}; 17 | namespace detail { 18 | template 19 | struct dispatch<2, swap_> { 20 | template 21 | using f = typename dispatch<2, C>::template f; 22 | }; 23 | } // namespace detail 24 | } // namespace tmp 25 | } // namespace boost 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/boost/tmp/detail/fusion_rebind.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_FUSION_REBIND_HPP_INCLUDED 2 | #define BOOST_TMP_FUSION_REBIND_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | #include "capabilities.hpp" 11 | namespace boost { 12 | namespace tmp { 13 | #ifdef BOOST_TMP_CPP14 14 | namespace fusion { 15 | // to make a metafunction fusion capable this traits must be specialized 16 | // with the rebound version of the metafunction to be used in fusion context 17 | template 18 | struct rebind; 19 | } // namespace fusion 20 | #endif 21 | } // namespace tmp 22 | } // namespace boost 23 | 24 | #endif -------------------------------------------------------------------------------- /include/boost/tmp/sequence/size.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_SIZE_HPP_INCLUDED 2 | #define BOOST_TMP_SIZE_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "../identity.hpp" 12 | #include "../vocabulary.hpp" 13 | namespace boost { 14 | namespace tmp { 15 | template 16 | struct size_ {}; 17 | namespace detail { 18 | template 19 | struct dispatch> { 20 | template 21 | using f = typename dispatch<1, C>::template f>; 22 | }; 23 | } // namespace detail 24 | } // namespace tmp 25 | } // namespace boost 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/boost/tmp/always.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_ALWAYS_HPP_INCLUDED 2 | #define BOOST_TMP_ALWAYS_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "detail/dispatch.hpp" 12 | #include "identity.hpp" 13 | 14 | namespace boost { 15 | namespace tmp { 16 | template 17 | struct always_ {}; 18 | 19 | namespace detail { 20 | template 21 | struct dispatch> { 22 | template 23 | using f = typename dispatch<1, C>::template f; 24 | }; 25 | } // namespace detail 26 | } // namespace tmp 27 | } // namespace boost 28 | #endif 29 | -------------------------------------------------------------------------------- /test/fold_right_test.hpp: -------------------------------------------------------------------------------- 1 | #include "test_util.hpp" 2 | #include "../include/boost/tmp/algorithm/fold_right.hpp" 3 | 4 | namespace fold_right_test { 5 | template 6 | using add = uint_<(T::value + U::value)>; 7 | int run() { 8 | uint_<1>{} = call_>, uint_<1>>{}; 9 | uint_<3>{} = call_>, uint_<1>, uint_<2>>{}; 10 | uint_<6>{} = call_>, uint_<1>, uint_<2>, uint_<3>>{}; 11 | uint_<10>{} = call_>, uint_<1>, uint_<2>, uint_<3>, uint_<4>>{}; 12 | uint_<20>{} = call_>, uint_<1>, uint_<1>, uint_<1>, uint_<1>, 13 | uint_<1>, uint_<1>, uint_<1>, uint_<1>, uint_<1>, uint_<1>, uint_<1>, 14 | uint_<2>, uint_<3>, uint_<4>>{}; 15 | return 0; 16 | } 17 | } // namespace fold_right_test 18 | -------------------------------------------------------------------------------- /include/boost/tmp/algorithm/partition.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_PARTITION_HPP_INCLUDED 2 | #define BOOST_TMP_PARTITION_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "filter.hpp" 12 | #include "remove_if.hpp" 13 | #include "../call.hpp" 14 | #include "../sequence/tee.hpp" 15 | #include "../vocabulary.hpp" 16 | 17 | namespace boost { 18 | namespace tmp { 19 | template 20 | struct partition_ {}; 21 | 22 | namespace detail { 23 | template 24 | struct dispatch> : dispatch, remove_if_, C>> { 25 | }; 26 | } // namespace detail 27 | } // namespace tmp 28 | } // namespace boost 29 | 30 | #endif -------------------------------------------------------------------------------- /include/boost/tmp/identity.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_IDENTITY_HPP_INCLUDED 2 | #define BOOST_TMP_IDENTITY_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "detail/capabilities.hpp" 12 | #include "detail/dispatch.hpp" 13 | #include "detail/fusion_rebind.hpp" 14 | namespace boost { 15 | namespace tmp { 16 | struct identity_ {}; 17 | #ifdef BOOST_TMP_CPP14 18 | namespace fusion { 19 | template <> 20 | struct rebind { 21 | using type = identity_; 22 | }; 23 | } // namespace fusion 24 | #endif 25 | namespace detail { 26 | template <> 27 | struct dispatch<1, identity_> { 28 | template 29 | using f = T; 30 | }; 31 | } // namespace detail 32 | } // namespace tmp 33 | } // namespace boost 34 | #endif 35 | -------------------------------------------------------------------------------- /include/boost/tmp/sequence/push_back.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_PUSH_BACK_HPP_INCLUDED 2 | #define BOOST_TMP_PUSH_BACK_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "../identity.hpp" 12 | #include "../vocabulary.hpp" 13 | namespace boost { 14 | namespace tmp { 15 | template 16 | struct push_back_ {}; 17 | namespace detail { 18 | template 19 | struct dispatch> { 20 | template 21 | using f = typename dispatch::template f; 23 | }; 24 | } // namespace detail 25 | } // namespace tmp 26 | } // namespace boost 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/boost/tmp/sequence/push_front.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_PUSH_FRONT_HPP_INCLUDED 2 | #define BOOST_TMP_PUSH_FRONT_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "../identity.hpp" 12 | #include "../vocabulary.hpp" 13 | namespace boost { 14 | namespace tmp { 15 | template 16 | struct push_front_ {}; 17 | namespace detail { 18 | template 19 | struct dispatch> { 20 | template 21 | using f = typename dispatch::template f; 23 | }; 24 | } // namespace detail 25 | } // namespace tmp 26 | } // namespace boost 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/boost/tmp/sequence/take.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_TAKE_HPP_INCLUDED 2 | #define BOOST_TMP_TAKE_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "drop.hpp" 12 | #include "rotate.hpp" 13 | #include "../vocabulary.hpp" 14 | 15 | namespace boost { 16 | namespace tmp { 17 | template , typename C = listify_> 18 | struct take_ {}; 19 | 20 | namespace detail { 21 | template 22 | struct dispatch> { 23 | template 24 | using f = typename dispatch< 25 | find_dispatch(sizeof...(Ts)), 26 | rotate_, C>>>::template f; 27 | }; 28 | } // namespace detail 29 | } // namespace tmp 30 | } // namespace boost 31 | 32 | #endif -------------------------------------------------------------------------------- /include/boost/tmp/algorithm/remove_if.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_REMOVE_IF_HPP_INCLUDED 2 | #define BOOST_TMP_REMOVE_IF_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "transform.hpp" 12 | #include "../always.hpp" 13 | #include "../call.hpp" 14 | #include "../detail/dispatch.hpp" 15 | #include "../if.hpp" 16 | #include "../sequence/join.hpp" 17 | #include "../vocabulary.hpp" 18 | 19 | namespace boost { 20 | namespace tmp { 21 | template 22 | struct remove_if_ {}; 23 | namespace detail { 24 | template 25 | struct dispatch> 26 | : dispatch>, listify_>, join_>> {}; 27 | } // namespace detail 28 | } // namespace tmp 29 | } // namespace boost 30 | 31 | #endif -------------------------------------------------------------------------------- /test/reverse_test.hpp: -------------------------------------------------------------------------------- 1 | #include "test_util.hpp" 2 | #include "../include/boost/tmp/sequence/reverse.hpp" 3 | # 4 | 5 | namespace reverse_test { 6 | int run() { 7 | using rhs = make_sequence_>>; 8 | using lhs = make_sequence_<>; 9 | call_>, extent>{} = 10 | call_>, extent>{}; 11 | 12 | list_>{} = call_>, uint_<1>>{}; 13 | 14 | list_, uint_<0>>{} = call_>, uint_<2>>{}; 15 | 16 | list_, uint_<1>, uint_<0>>{} = 17 | call_>, uint_<3>>{}; 18 | 19 | list_, uint_<2>, uint_<1>, uint_<0>>{} = 20 | call_>, uint_<4>>{}; 21 | 22 | list_, uint_<3>, uint_<2>, uint_<1>, uint_<0>>{} = 23 | call_>, uint_<5>>{}; 24 | 25 | return 0; 26 | } 27 | } // namespace reverse_test 28 | -------------------------------------------------------------------------------- /include/boost/tmp/vocabulary.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_VOCABULARY_HPP_INCLUDED 2 | #define BOOST_TMP_VOCABULARY_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "always.hpp" 12 | #include "lift.hpp" 13 | 14 | namespace boost { 15 | namespace tmp { 16 | template 17 | struct list_ {}; 18 | 19 | using listify_ = lift_; 20 | 21 | template 22 | struct uint_ { 23 | static constexpr unsigned long long value = V; 24 | }; 25 | template 26 | struct int_ { 27 | static constexpr long long value = I; 28 | }; 29 | template 30 | struct bool_ { 31 | static constexpr bool value = B; 32 | }; 33 | 34 | using true_ = bool_; 35 | using false_ = bool_; 36 | 37 | struct nothing_ {}; 38 | } // namespace tmp 39 | } // namespace boost 40 | #endif 41 | -------------------------------------------------------------------------------- /include/boost/tmp/algorithm/replace_if.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_REPLACE_IF_HPP_INCLUDED 2 | #define BOOST_TMP_REPLACE_IF_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "transform.hpp" 12 | #include "../always.hpp" 13 | #include "../call.hpp" 14 | #include "../detail/dispatch.hpp" 15 | #include "../if.hpp" 16 | #include "../sequence/join.hpp" 17 | #include "../vocabulary.hpp" 18 | 19 | namespace boost { 20 | namespace tmp { 21 | template 22 | struct replace_if_ {}; 23 | namespace detail { 24 | template 25 | struct dispatch> 26 | : dispatch, identity_>, C>> {}; 27 | } // namespace detail 28 | } // namespace tmp 29 | } // namespace boost 30 | 31 | #endif -------------------------------------------------------------------------------- /include/boost/tmp/sequence/pop_front.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_POP_FRONT_HPP_INCLUDED 2 | #define BOOST_TMP_POP_FRONT_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "../identity.hpp" 12 | #include "../vocabulary.hpp" 13 | namespace boost { 14 | namespace tmp { 15 | template 16 | struct pop_front_ {}; 17 | namespace detail { 18 | template 19 | struct dispatch> { 20 | template 21 | using f = typename dispatch::template f; 22 | }; 23 | template 24 | struct dispatch<0, pop_front_> { 25 | template 26 | using f = typename dispatch<1, C>::template f; 27 | }; 28 | } // namespace detail 29 | } // namespace tmp 30 | } // namespace boost 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /include/boost/tmp/algorithm/count_if.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_COUNT_IF_HPP_INCLUDED 2 | #define BOOST_TMP_COUNT_IF_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "transform.hpp" 12 | #include "../call.hpp" 13 | #include "../detail/dispatch.hpp" 14 | #include "../if.hpp" 15 | #include "../sequence/join.hpp" 16 | #include "../sequence/size.hpp" 17 | #include "../vocabulary.hpp" 18 | 19 | namespace boost { 20 | namespace tmp { 21 | template 22 | struct count_if_ {}; 23 | namespace detail { 24 | template 25 | struct dispatch> 26 | : dispatch>, always_>>, 27 | join_>>> {}; 28 | } // namespace detail 29 | } // namespace tmp 30 | } // namespace boost 31 | 32 | #endif -------------------------------------------------------------------------------- /test/contains_test.hpp: -------------------------------------------------------------------------------- 1 | #include "test_util.hpp" 2 | #include "../include/boost/tmp/algorithm/contains.hpp" 3 | #include "../include/boost/tmp/comparison.hpp" 4 | namespace contains_test { 5 | template 6 | struct x; 7 | 8 | using xs0 = list_, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>, x<8>, x<9>, x<10>>; 9 | 10 | using result0 = call_>>>, xs0>; 11 | using result1 = call_>>>, xs0>; 12 | using result2 = call_>>>, xs0>; 13 | using result3 = call_>>>, xs0>; 14 | 15 | // fusion 16 | /* 17 | #ifdef BOOST_TMP_CPP14 18 | int i = 1; 19 | true_ ll = pack_(false, 'a', i, 2, true) >>= 20 | contains_{} | 21 | [](auto l) { return l; }; 22 | auto lll = pack_(false, 'a', i, 2, true) >>= 23 | contains_>>{} | 24 | [](auto l) { return l; }; 25 | #endif 26 | */ 27 | int run() { 28 | 29 | return 0; 30 | } 31 | } // namespace contains_test -------------------------------------------------------------------------------- /include/boost/tmp/comparison.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_COMPARISON_HPP_INCLUDED 2 | #define BOOST_TMP_COMPARISON_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include 12 | #include "vocabulary.hpp" 13 | 14 | namespace boost { 15 | namespace tmp { 16 | template 17 | struct is_ {}; 18 | 19 | template 20 | struct less_ {}; 21 | 22 | namespace detail { 23 | template 24 | struct dispatch<1, is_> { 25 | template 26 | using f = typename dispatch<1, C>::template f::value>>; 27 | }; 28 | 29 | template 30 | struct dispatch<2, less_> { 31 | template 32 | using f = typename dispatch<1, C>::template f < bool_>; 33 | }; 34 | } // namespace detail 35 | } // namespace tmp 36 | } // namespace boost 37 | #endif 38 | -------------------------------------------------------------------------------- /test/logic_test.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "test_util.hpp" 3 | #include "../include/boost/tmp/logic.hpp" 4 | 5 | namespace logic_test { 6 | template 7 | using is_even = bool_<(T::value % 2 == 0)>; 8 | int run() { 9 | 10 | bool_{} = call_>, int_<1>, int_<1>, int_<1>, int_<1>, int_<1>, 11 | int_<1>, int_<1>, int_<1>, int_<1>>{}; 12 | 13 | bool_{} = call_>, int_<2>, int_<1>, int_<1>, int_<1>, int_<1>, 14 | int_<1>, int_<1>, int_<1>, int_<2>>{}; 15 | 16 | bool_{} = call_>, int_<2>, int_<2>, int_<2>>{}; 17 | 18 | bool_{} = call_>, int_<1>, int_<1>, int_<1>, int_<1>, int_<1>, 19 | int_<1>, int_<1>, int_<1>, int_<1>>{}; 20 | 21 | bool_{} = call_>, int_<1>, int_<1>, int_<1>, int_<1>, int_<1>, 22 | int_<1>, int_<1>, int_<1>, int_<2>>{}; 23 | 24 | bool_{} = call_>, int_<2>, int_<2>, int_<2>>{}; 25 | 26 | return 0; 27 | } 28 | } // namespace logic_test -------------------------------------------------------------------------------- /include/boost/tmp/detail/dispatch.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_DISPATCH_HPP_INCLUDED 2 | #define BOOST_TMP_DISPATCH_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | namespace boost { 12 | namespace tmp { 13 | namespace detail { 14 | constexpr unsigned find_dispatch(unsigned n) { 15 | return n <= 8 ? n : 16 | n < 16 ? 17 | 9 : 18 | n == 16 ? 19 | 16 : 20 | n < 32 ? 21 | 17 : 22 | n == 32 ? 23 | 32 : 24 | n < 64 ? 33 : n == 64 ? 64 : n < 128 ? 65 : n == 128 ? 128 : 129; 25 | } 26 | 27 | template 28 | struct dispatch; 29 | 30 | template 31 | struct dispatch_unknown { 32 | template 33 | using f = typename dispatch::template f; 34 | }; 35 | } // namespace detail 36 | } // namespace tmp 37 | } // namespace boost 38 | #endif 39 | -------------------------------------------------------------------------------- /include/boost/tmp/sequence/erase.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_ERASE_HPP_INCLUDED 2 | #define BOOST_TMP_ERASE_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "drop.hpp" 12 | #include "pop_front.hpp" 13 | #include "rotate.hpp" 14 | #include "../vocabulary.hpp" 15 | 16 | namespace boost { 17 | namespace tmp { 18 | template , typename C = listify_> 19 | struct erase_ {}; 20 | 21 | namespace detail { 22 | template 23 | struct dispatch> { 24 | template 25 | using f = typename dispatch< 26 | N, 27 | rotate_, C>>>>:: 28 | template f; 29 | }; 30 | template 31 | struct dispatch<0, erase_> { 32 | template 33 | using f = typename dispatch<1, C>::template f; 34 | }; 35 | } // namespace detail 36 | } // namespace tmp 37 | } // namespace boost 38 | 39 | #endif -------------------------------------------------------------------------------- /include/boost/tmp/algorithm/transform.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_TRANSFORM_HPP_INCLUDED 2 | #define BOOST_TMP_TRANSFORM_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "../call.hpp" 12 | #include "../vocabulary.hpp" 13 | 14 | namespace boost { 15 | namespace tmp { 16 | template 17 | struct transform_ {}; 18 | namespace detail { 19 | template 20 | struct dispatch> { 21 | template 22 | using f = typename dispatch::template f< 23 | typename dispatch<1, F>::template f...>; 24 | }; 25 | 26 | template class F, typename FC, typename C> 27 | struct dispatch, C>> { 28 | template 29 | using f = typename dispatch<(N + (N > sizeof...(Ts))), C>::template f...>; 30 | }; 31 | } // namespace detail 32 | } // namespace tmp 33 | } // namespace boost 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/boost/tmp/try.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_TMP_TRY_HPP_INCLUDED 2 | #define BOOST_TMP_TRY_HPP_INCLUDED 3 | 4 | // Copyright 2018 Odin Holmes. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // 8 | // See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt 10 | 11 | #include "always.hpp" 12 | #include "detail/dispatch.hpp" 13 | #include "identity.hpp" 14 | #include "sequence/unpack.hpp" 15 | #include "vocabulary.hpp" 16 | 17 | namespace boost { 18 | namespace tmp { 19 | 20 | template