2011-10-27 02:24:47 +00:00
|
|
|
#ifndef SPROUT_DETAIL_CONTAINER_COMPLATE_BACKWARD_HPP
|
|
|
|
#define SPROUT_DETAIL_CONTAINER_COMPLATE_BACKWARD_HPP
|
|
|
|
|
|
|
|
#include <type_traits>
|
|
|
|
#include <sprout/config.hpp>
|
2012-03-31 07:24:13 +00:00
|
|
|
#include <sprout/container/traits.hpp>
|
|
|
|
#include <sprout/container/functions.hpp>
|
2011-10-27 02:24:47 +00:00
|
|
|
#include <sprout/iterator/operation.hpp>
|
|
|
|
#include <sprout/algorithm/fixed/result_of.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace detail {
|
|
|
|
template<typename Result, typename... Args>
|
2012-04-04 13:23:41 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
2012-03-31 07:24:13 +00:00
|
|
|
sprout::container_traits<Result>::static_size == sizeof...(Args),
|
2011-10-27 02:24:47 +00:00
|
|
|
typename sprout::fixed::result_of::algorithm<Result>::type
|
2012-10-05 15:58:56 +00:00
|
|
|
>::type
|
|
|
|
container_complate_backward_2(Result const& result, Args const&... args) {
|
2012-03-31 07:24:13 +00:00
|
|
|
return sprout::remake<Result>(result, sprout::size(result), args...);
|
2011-10-27 02:24:47 +00:00
|
|
|
}
|
|
|
|
template<typename Result, typename... Args>
|
2012-04-04 13:23:41 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
2012-03-31 07:24:13 +00:00
|
|
|
sprout::container_traits<Result>::static_size != sizeof...(Args),
|
2011-10-27 02:24:47 +00:00
|
|
|
typename sprout::fixed::result_of::algorithm<Result>::type
|
2012-10-05 15:58:56 +00:00
|
|
|
>::type
|
|
|
|
container_complate_backward_2(Result const& result, Args const&... args) {
|
2012-03-31 07:24:13 +00:00
|
|
|
return container_complate_backward_2(result, *sprout::prev(sprout::internal_end(result), sizeof...(Args) + 1), args...);
|
2011-10-27 02:24:47 +00:00
|
|
|
}
|
|
|
|
template<typename Result, typename... Args>
|
2012-04-04 13:23:41 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
2012-03-31 07:24:13 +00:00
|
|
|
sprout::container_traits<Result>::static_size == sizeof...(Args),
|
2011-10-27 02:24:47 +00:00
|
|
|
typename sprout::fixed::result_of::algorithm<Result>::type
|
2012-10-05 15:58:56 +00:00
|
|
|
>::type
|
|
|
|
container_complate_backward_1(
|
2011-10-27 02:24:47 +00:00
|
|
|
Result const& result,
|
2013-07-22 13:00:09 +00:00
|
|
|
typename sprout::container_traits<Result>::difference_type,
|
2011-10-27 02:24:47 +00:00
|
|
|
Args const&... args
|
|
|
|
)
|
|
|
|
{
|
2012-03-31 07:24:13 +00:00
|
|
|
return sprout::remake<Result>(result, sprout::size(result), args...);
|
2011-10-27 02:24:47 +00:00
|
|
|
}
|
|
|
|
template<typename Result, typename... Args>
|
2012-04-04 13:23:41 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
2012-03-31 07:24:13 +00:00
|
|
|
sprout::container_traits<Result>::static_size != sizeof...(Args),
|
2011-10-27 02:24:47 +00:00
|
|
|
typename sprout::fixed::result_of::algorithm<Result>::type
|
2012-10-05 15:58:56 +00:00
|
|
|
>::type
|
|
|
|
container_complate_backward_1(
|
2011-10-27 02:24:47 +00:00
|
|
|
Result const& result,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<Result>::difference_type remain,
|
2011-10-27 02:24:47 +00:00
|
|
|
Args const&... args
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return remain != 0
|
2012-03-31 07:24:13 +00:00
|
|
|
? container_complate_backward_1(result, remain - 1, args..., *sprout::prev(sprout::internal_end(result), remain))
|
2011-10-27 02:24:47 +00:00
|
|
|
: container_complate_backward_2(result, args...)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
template<typename Result, typename... Args>
|
2012-04-04 13:23:41 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
2012-03-31 07:24:13 +00:00
|
|
|
sprout::container_traits<Result>::static_size == sizeof...(Args),
|
2011-10-27 02:24:47 +00:00
|
|
|
typename sprout::fixed::result_of::algorithm<Result>::type
|
2012-10-05 15:58:56 +00:00
|
|
|
>::type
|
|
|
|
container_complate_backward(Result const& result, Args const&... args) {
|
2012-03-31 07:24:13 +00:00
|
|
|
return sprout::remake<Result>(result, sprout::size(result), args...);
|
2011-10-27 02:24:47 +00:00
|
|
|
}
|
|
|
|
template<typename Result, typename... Args>
|
2012-04-04 13:23:41 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
2012-03-31 07:24:13 +00:00
|
|
|
sprout::container_traits<Result>::static_size != sizeof...(Args),
|
2011-10-27 02:24:47 +00:00
|
|
|
typename sprout::fixed::result_of::algorithm<Result>::type
|
2012-10-05 15:58:56 +00:00
|
|
|
>::type
|
|
|
|
container_complate_backward(Result const& result, Args const&... args) {
|
2012-03-31 07:24:13 +00:00
|
|
|
return container_complate_backward_1(result, sprout::internal_end_offset_backward(result), args...);
|
2011-10-27 02:24:47 +00:00
|
|
|
}
|
|
|
|
} // namespace detail
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_DETAIL_CONTAINER_COMPLATE_BACKWARD_HPP
|