2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2015-01-10 10:13:57 +00:00
|
|
|
Copyright (c) 2011-2015 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)
|
|
|
|
=============================================================================*/
|
2012-06-22 10:14:21 +00:00
|
|
|
#ifndef SPROUT_PIT_CONTAINER_HPP
|
|
|
|
#define SPROUT_PIT_CONTAINER_HPP
|
|
|
|
|
|
|
|
#include <type_traits>
|
|
|
|
#include <sprout/utility/forward.hpp>
|
|
|
|
#include <sprout/pit/pit.hpp>
|
|
|
|
#include <sprout/container/traits.hpp>
|
|
|
|
#include <sprout/container/functions.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
2013-01-16 18:53:17 +00:00
|
|
|
namespace detail {
|
|
|
|
template<typename Container, typename = void>
|
|
|
|
struct pit_container_construct_traits;
|
|
|
|
|
|
|
|
template<typename Container>
|
|
|
|
struct pit_container_construct_traits<
|
|
|
|
sprout::pit<Container>,
|
|
|
|
typename std::enable_if<sprout::is_fixed_container<Container>::value>::type
|
|
|
|
> {
|
|
|
|
public:
|
|
|
|
typedef typename sprout::container_construct_traits<Container>::copied_type copied_type;
|
|
|
|
public:
|
|
|
|
template<typename Cont>
|
|
|
|
static SPROUT_CONSTEXPR copied_type
|
2013-07-22 13:00:09 +00:00
|
|
|
deep_copy(Cont&&) {
|
2013-01-16 18:53:17 +00:00
|
|
|
return copied_type();
|
|
|
|
}
|
|
|
|
template<typename... Args>
|
|
|
|
static SPROUT_CONSTEXPR copied_type
|
|
|
|
make(Args&&... args) {
|
2014-02-22 07:32:51 +00:00
|
|
|
return sprout::make<copied_type>(SPROUT_FORWARD(Args, args)...);
|
2013-01-16 18:53:17 +00:00
|
|
|
}
|
|
|
|
template<typename Cont, typename... Args>
|
|
|
|
static SPROUT_CONSTEXPR copied_type
|
|
|
|
remake(Cont&& cont, typename sprout::container_traits<sprout::pit<Container> >::difference_type size, Args&&... args) {
|
2014-02-22 07:32:51 +00:00
|
|
|
return sprout::remake<copied_type>(SPROUT_FORWARD(Cont, cont), size, SPROUT_FORWARD(Args, args)...);
|
2013-01-16 18:53:17 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename Container>
|
|
|
|
struct pit_container_construct_traits<
|
|
|
|
sprout::pit<Container>,
|
|
|
|
typename std::enable_if<!sprout::is_fixed_container<Container>::value>::type
|
|
|
|
> {
|
|
|
|
public:
|
|
|
|
typedef typename sprout::container_construct_traits<Container>::copied_type copied_type;
|
|
|
|
public:
|
|
|
|
template<typename Cont>
|
|
|
|
static SPROUT_CONSTEXPR copied_type
|
2013-07-22 13:00:09 +00:00
|
|
|
deep_copy(Cont&&) {
|
2013-01-16 18:53:17 +00:00
|
|
|
return copied_type();
|
|
|
|
}
|
|
|
|
template<typename... Args>
|
|
|
|
static SPROUT_CONSTEXPR copied_type
|
|
|
|
make(Args&&... args) {
|
2014-02-22 07:32:51 +00:00
|
|
|
return sprout::make<copied_type>(SPROUT_FORWARD(Args, args)...);
|
2013-01-16 18:53:17 +00:00
|
|
|
}
|
|
|
|
template<typename Cont, typename... Args>
|
|
|
|
static SPROUT_CONSTEXPR copied_type
|
|
|
|
remake(Cont&& cont, typename sprout::container_traits<sprout::pit<Container> >::difference_type size, Args&&... args) {
|
2014-02-22 07:32:51 +00:00
|
|
|
return sprout::remake<copied_type>(SPROUT_FORWARD(Cont, cont), size, SPROUT_FORWARD(Args, args)...);
|
2013-01-16 18:53:17 +00:00
|
|
|
}
|
|
|
|
template<typename Cont, typename InputIterator>
|
|
|
|
static SPROUT_CONSTEXPR copied_type
|
2013-07-22 13:00:09 +00:00
|
|
|
remake(Cont&&, typename sprout::container_traits<sprout::pit<Container> >::difference_type, InputIterator first, InputIterator last) {
|
2013-01-16 18:53:17 +00:00
|
|
|
return copied_type(first, last);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace detail
|
2012-06-22 10:14:21 +00:00
|
|
|
//
|
|
|
|
// container_construct_traits
|
|
|
|
//
|
|
|
|
template<typename Container>
|
2013-01-16 18:53:17 +00:00
|
|
|
struct container_construct_traits<sprout::pit<Container> >
|
|
|
|
: public sprout::detail::pit_container_construct_traits<sprout::pit<Container> >
|
|
|
|
{};
|
2012-06-22 10:14:21 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// container_transform_traits
|
|
|
|
//
|
|
|
|
template<typename Container>
|
|
|
|
struct container_transform_traits<sprout::pit<Container> > {
|
|
|
|
public:
|
|
|
|
template<typename sprout::container_traits<sprout::pit<Container> >::size_type Size>
|
|
|
|
struct rebind_size {
|
|
|
|
public:
|
|
|
|
typedef sprout::pit<
|
|
|
|
typename sprout::container_transform_traits<Container>::template rebind_size<Size>::type
|
|
|
|
> type;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_PIT_CONTAINER_HPP
|