/*============================================================================= Copyright (c) 2011-2013 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout 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) =============================================================================*/ #ifndef SPROUT_WEED_ATTR_CNV_SHIFT_LEFT_HPP #define SPROUT_WEED_ATTR_CNV_SHIFT_LEFT_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace sprout { namespace weed { namespace attr_cnv { // // shift_left // // container >> container -> container template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_same_container::value, typename sprout::weed::attr_cnv::results::shift_left::type >::type shift_left(T const& t, U const& u) { return sprout::fixed::append_back(t, u); } // container >> V -> container template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_container_and_elem::value, typename sprout::weed::attr_cnv::results::shift_left::type >::type shift_left(T const& t, U const& u) { return sprout::fixed::push_back(t, u); } // V >> container -> container template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_elem_and_container::value, typename sprout::weed::attr_cnv::results::shift_left::type >::type shift_left(T const& t, U const& u) { return sprout::fixed::push_front(u, t); } // tuple >> tuple -> tuple template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_both_tuple::value, typename sprout::weed::attr_cnv::results::shift_left::type >::type shift_left(T const& t, U const& u) { return sprout::tuples::append_back(t, u); } // tuple >> V -> tuple template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_tuple_and_elem::value, typename sprout::weed::attr_cnv::results::shift_left::type >::type shift_left(T const& t, U const& u) { return sprout::tuples::push_back(t, u); } // V >> tuple -> tuple template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_elem_and_tuple::value, typename sprout::weed::attr_cnv::results::shift_left::type >::type shift_left(T const& t, U const& u) { return sprout::tuples::push_front(u, t); } // V >> V -> container template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_same_elem::value, typename sprout::weed::attr_cnv::results::shift_left::type >::type shift_left(T const& t, U const& u) { typedef typename sprout::weed::attr_cnv::results::shift_left::type type; return sprout::make(t, u); } // V >> W -> tuple template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_different_elem::value, typename sprout::weed::attr_cnv::results::shift_left::type >::type shift_left(T const& t, U const& u) { return typename sprout::weed::attr_cnv::results::shift_left::type(t, u); } // V >> unused -> V template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_elem_and_unused::value, typename sprout::weed::attr_cnv::results::shift_left::type >::type shift_left(T const& t, U const&) { return t; } // unused >> V -> V template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_unused_and_elem::value, typename sprout::weed::attr_cnv::results::shift_left::type >::type shift_left(T const&, U const& u) { return u; } // unused >> unused -> unused template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::detail::is_both_unused::value, typename sprout::weed::attr_cnv::results::shift_left::type >::type shift_left(T const&, U const&) { return sprout::weed::unused(); } } // namespace attr_cnv } // namespace weed } // namespace sprout #endif // #ifndef SPROUT_WEED_ATTR_CNV_SHIFT_LEFT_HPP