diff --git a/.travis.yml b/.travis.yml index c168ae3..ea18019 100644 --- a/.travis.yml +++ b/.travis.yml @@ -95,6 +95,7 @@ matrix: env: - TOOLSET=clang++-3.9 - CPP_EXTRA_FEATURES="cxx_relaxed_constexpr" + - LIBCXX=On - os: osx compiler: clang diff --git a/src/kvasir/mpl/algorithm/group.hpp b/src/kvasir/mpl/algorithm/group.hpp index 8ac4fa3..4ed0836 100644 --- a/src/kvasir/mpl/algorithm/group.hpp +++ b/src/kvasir/mpl/algorithm/group.hpp @@ -13,8 +13,8 @@ #include "../sequence/take.hpp" #include "../types/int.hpp" #include "../types/list.hpp" +#include "../types/traits.hpp" #include "../utility/conditional.hpp" -#include "../utility/is_same.hpp" namespace kvasir { namespace mpl { diff --git a/src/kvasir/mpl/algorithm/index_if.hpp b/src/kvasir/mpl/algorithm/index_if.hpp new file mode 100644 index 0000000..66d492f --- /dev/null +++ b/src/kvasir/mpl/algorithm/index_if.hpp @@ -0,0 +1,26 @@ +// Copyright Odin Holmes 2016. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#pragma once +#include +#include "make_sequence.hpp" +#include "zip_with.hpp" +#include "../functional/bind.hpp" +#include "../functional/flow.hpp" +#include "../sequence/at.hpp" +#include "../sequence/join.hpp" + +namespace kvasir { + namespace mpl { + namespace detail { + template + struct index_if { + template + using f = typename zip_fixed, F>, front>, always>>, + call, uint_>, + join>::template f; + }; + } // namespace detail + } // namespace mpl +} // namespace kvasir diff --git a/src/kvasir/mpl/algorithm/transform.hpp b/src/kvasir/mpl/algorithm/transform.hpp index 12b44c7..373dc32 100644 --- a/src/kvasir/mpl/algorithm/transform.hpp +++ b/src/kvasir/mpl/algorithm/transform.hpp @@ -13,7 +13,7 @@ namespace kvasir { namespace mpl { /// \brief executes the continuation `F` on every element in the input pack passing the /// results to the continuation `C` - template + template struct transform { template using f = typename dcall::template f...>; diff --git a/src/kvasir/mpl/algorithm/zip_with.hpp b/src/kvasir/mpl/algorithm/zip_with.hpp index 9488c39..3006b81 100644 --- a/src/kvasir/mpl/algorithm/zip_with.hpp +++ b/src/kvasir/mpl/algorithm/zip_with.hpp @@ -11,10 +11,14 @@ #include "../types/nothing.hpp" #include "../utility/always.hpp" +#include "../sequence/drop.hpp" #include "../sequence/pop_front.hpp" #include "../sequence/push_front.hpp" #include "../sequence/size.hpp" +#include "../algorithm/make_sequence.hpp" +#include "../algorithm/rotate.hpp" + namespace kvasir { namespace mpl { namespace detail { @@ -89,7 +93,45 @@ namespace kvasir { template using f = typename detail::zip_with_unpack::f; }; + namespace detail { + /// \brief n-ary version of transform with all but one of the sequences as fixed + /// parameters + template + struct zip_fixed { + private: + using fixed_size = uint_<(sizeof...(Ls) - 1)>; + using C = typename drop::template f; + public: + template + using f = + typename rotate, + pop_front>>::template f>; + }; + /// \exclude + template class L, typename... Ls, typename C> + struct zip_fixed, C> { + template + using f = typename dcall::template f< + typename dcall::template f...>; + }; + /// \exclude + template class L1, template class L2, + typename... L1s, typename... L2s, typename C> + struct zip_fixed, L2, C> { + template + using f = typename dcall::template f< + typename dcall::template f...>; + }; + + /// \brief binary transform of an index sequence and the dynamic input sequence + template + struct zip_with_index { + template + using f = typename zip_fixed, uint_>, + C>::template f; + }; + } // namespace detail namespace eager { template