2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2014-01-08 07:48:12 +00:00
|
|
|
Copyright (c) 2011-2014 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
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)
|
|
|
|
=============================================================================*/
|
2014-05-29 16:22:00 +00:00
|
|
|
#ifndef SPROUT_WEED_ATTR_CNV_RESULTS_SHIFT_LEFT_HPP
|
|
|
|
#define SPROUT_WEED_ATTR_CNV_RESULTS_SHIFT_LEFT_HPP
|
2011-11-13 08:54:38 +00:00
|
|
|
|
|
|
|
#include <type_traits>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/string.hpp>
|
2013-02-07 14:12:57 +00:00
|
|
|
#include <sprout/array/array.hpp>
|
2011-11-13 08:54:38 +00:00
|
|
|
#include <sprout/operation/fixed/append_back.hpp>
|
|
|
|
#include <sprout/operation/fixed/push_back.hpp>
|
|
|
|
#include <sprout/operation/fixed/push_front.hpp>
|
|
|
|
#include <sprout/tuple/operation/append_back.hpp>
|
|
|
|
#include <sprout/tuple/operation/push_back.hpp>
|
|
|
|
#include <sprout/tuple/operation/push_front.hpp>
|
2013-03-25 03:43:47 +00:00
|
|
|
#include <sprout/type_traits/identity.hpp>
|
2011-11-13 08:54:38 +00:00
|
|
|
#include <sprout/weed/unused.hpp>
|
|
|
|
#include <sprout/weed/traits/type/is_char_type.hpp>
|
|
|
|
#include <sprout/weed/detail/is_same_container.hpp>
|
|
|
|
#include <sprout/weed/detail/is_container_and_elem.hpp>
|
|
|
|
#include <sprout/weed/detail/is_elem_and_container.hpp>
|
|
|
|
#include <sprout/weed/detail/is_both_tuple.hpp>
|
|
|
|
#include <sprout/weed/detail/is_tuple_and_elem.hpp>
|
|
|
|
#include <sprout/weed/detail/is_elem_and_tuple.hpp>
|
|
|
|
#include <sprout/weed/detail/is_same_elem.hpp>
|
|
|
|
#include <sprout/weed/detail/is_different_elem.hpp>
|
|
|
|
#include <sprout/weed/detail/is_elem_and_unused.hpp>
|
|
|
|
#include <sprout/weed/detail/is_unused_and_elem.hpp>
|
|
|
|
#include <sprout/weed/detail/is_both_unused.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace weed {
|
|
|
|
namespace attr_cnv {
|
2013-11-20 13:04:11 +00:00
|
|
|
namespace results {
|
2011-11-13 08:54:38 +00:00
|
|
|
//
|
|
|
|
// shift_left
|
|
|
|
//
|
|
|
|
template<typename T, typename U, typename = void>
|
|
|
|
struct shift_left;
|
|
|
|
// container<V, N> >> container<V, M> -> container<V, N + M>
|
|
|
|
template<typename T, typename U>
|
|
|
|
struct shift_left<
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
typename std::enable_if<
|
|
|
|
sprout::weed::detail::is_same_container<T, U>::value
|
|
|
|
>::type
|
2013-03-25 03:43:47 +00:00
|
|
|
>
|
2013-11-20 13:04:11 +00:00
|
|
|
: public sprout::fixed::results::append_back<T, U>
|
2013-03-25 03:43:47 +00:00
|
|
|
{};
|
2011-11-13 08:54:38 +00:00
|
|
|
// container<V, N> >> V -> container<V, N + 1>
|
|
|
|
template<typename T, typename U>
|
|
|
|
struct shift_left<
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
typename std::enable_if<
|
|
|
|
sprout::weed::detail::is_container_and_elem<T, U>::value
|
|
|
|
>::type
|
2013-03-25 03:43:47 +00:00
|
|
|
>
|
2013-11-20 13:04:11 +00:00
|
|
|
: public sprout::fixed::results::push_back<T, U>
|
2013-03-25 03:43:47 +00:00
|
|
|
{};
|
2011-11-13 08:54:38 +00:00
|
|
|
// V >> container<V, N> -> container<V, N + 1>
|
|
|
|
template<typename T, typename U>
|
|
|
|
struct shift_left<
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
typename std::enable_if<
|
|
|
|
sprout::weed::detail::is_elem_and_container<T, U>::value
|
|
|
|
>::type
|
2013-03-25 03:43:47 +00:00
|
|
|
>
|
2013-11-20 13:04:11 +00:00
|
|
|
: public sprout::fixed::results::push_front<U, T>
|
2013-03-25 03:43:47 +00:00
|
|
|
{};
|
2011-11-13 08:54:38 +00:00
|
|
|
// tuple<Vs...> >> tuple<Ws...> -> tuple<Vs..., Ws...>
|
|
|
|
template<typename T, typename U>
|
|
|
|
struct shift_left<
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
typename std::enable_if<
|
|
|
|
sprout::weed::detail::is_both_tuple<T, U>::value
|
|
|
|
>::type
|
2013-03-25 03:43:47 +00:00
|
|
|
>
|
2013-11-20 13:04:11 +00:00
|
|
|
: public sprout::tuples::results::append_back<T, U>
|
2013-03-25 03:43:47 +00:00
|
|
|
{};
|
2011-11-13 08:54:38 +00:00
|
|
|
// tuple<Vs...> >> V -> tuple<Vs..., V>
|
|
|
|
template<typename T, typename U>
|
|
|
|
struct shift_left<
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
typename std::enable_if<
|
|
|
|
sprout::weed::detail::is_tuple_and_elem<T, U>::value
|
|
|
|
>::type
|
2013-03-25 03:43:47 +00:00
|
|
|
>
|
2013-11-20 13:04:11 +00:00
|
|
|
: public sprout::tuples::results::push_back<T, U>
|
2013-03-25 03:43:47 +00:00
|
|
|
{};
|
2011-11-13 08:54:38 +00:00
|
|
|
// V >> tuple<Vs...> -> tuple<V, Vs...>
|
|
|
|
template<typename T, typename U>
|
|
|
|
struct shift_left<
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
typename std::enable_if<
|
|
|
|
sprout::weed::detail::is_elem_and_tuple<T, U>::value
|
|
|
|
>::type
|
2013-03-25 03:43:47 +00:00
|
|
|
>
|
2013-11-20 13:04:11 +00:00
|
|
|
: public sprout::tuples::results::push_front<U, T>
|
2013-03-25 03:43:47 +00:00
|
|
|
{};
|
2011-11-13 08:54:38 +00:00
|
|
|
// V >> V -> container<V, 2>
|
|
|
|
template<typename T, typename U>
|
|
|
|
struct shift_left<
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
typename std::enable_if<
|
|
|
|
sprout::weed::detail::is_same_elem<T, U>::value
|
|
|
|
>::type
|
2013-03-25 03:43:47 +00:00
|
|
|
>
|
|
|
|
: public std::conditional<
|
2011-11-13 08:54:38 +00:00
|
|
|
sprout::weed::traits::is_char_type<T>::value,
|
|
|
|
sprout::basic_string<T, 2>,
|
|
|
|
sprout::array<T, 2>
|
2013-03-25 03:43:47 +00:00
|
|
|
>
|
|
|
|
{};
|
2011-11-13 08:54:38 +00:00
|
|
|
// V >> W -> tuple<V, W>
|
|
|
|
template<typename T, typename U>
|
|
|
|
struct shift_left<
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
typename std::enable_if<
|
|
|
|
sprout::weed::detail::is_different_elem<T, U>::value
|
|
|
|
>::type
|
2013-03-25 03:43:47 +00:00
|
|
|
>
|
|
|
|
: public sprout::identity<sprout::tuples::tuple<T, U> >
|
|
|
|
{};
|
2011-11-13 08:54:38 +00:00
|
|
|
// V >> unused -> V
|
|
|
|
template<typename T, typename U>
|
|
|
|
struct shift_left<
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
typename std::enable_if<
|
|
|
|
sprout::weed::detail::is_elem_and_unused<T, U>::value
|
|
|
|
>::type
|
2013-03-25 03:43:47 +00:00
|
|
|
>
|
|
|
|
: public sprout::identity<T>
|
|
|
|
{};
|
2011-11-13 08:54:38 +00:00
|
|
|
// unused >> V -> V
|
|
|
|
template<typename T, typename U>
|
|
|
|
struct shift_left<
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
typename std::enable_if<
|
|
|
|
sprout::weed::detail::is_unused_and_elem<T, U>::value
|
|
|
|
>::type
|
2013-03-25 03:43:47 +00:00
|
|
|
>
|
|
|
|
: public sprout::identity<U>
|
|
|
|
{};
|
2011-11-13 08:54:38 +00:00
|
|
|
// unused >> unused -> unused
|
|
|
|
template<typename T, typename U>
|
|
|
|
struct shift_left<
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
typename std::enable_if<
|
|
|
|
sprout::weed::detail::is_both_unused<T, U>::value
|
|
|
|
>::type
|
2013-03-25 03:43:47 +00:00
|
|
|
>
|
|
|
|
: public sprout::identity<sprout::weed::unused>
|
|
|
|
{};
|
2013-11-20 13:04:11 +00:00
|
|
|
} // namespace results
|
2011-11-13 08:54:38 +00:00
|
|
|
} // namespace attr_cnv
|
|
|
|
} // namespace weed
|
|
|
|
} // namespace sprout
|
|
|
|
|
2014-05-29 16:22:00 +00:00
|
|
|
#endif // #ifndef SPROUT_WEED_ATTR_CNV_RESULTS_SHIFT_LEFT_HPP
|