1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/sprout/tuple/operation/pop_back.hpp

47 lines
1.3 KiB
C++
Raw Normal View History

2012-07-18 12:44:31 +00:00
#ifndef SPROUT_TUPLE_OPERATION_POP_BACK_HPP
#define SPROUT_TUPLE_OPERATION_POP_BACK_HPP
#include <sprout/config.hpp>
2013-04-06 04:06:51 +00:00
#include <sprout/index_tuple/metafunction.hpp>
2012-07-18 12:44:31 +00:00
#include <sprout/tuple/tuple.hpp>
#include <sprout/tuple/functions.hpp>
#include <sprout/type/operation/pop_back.hpp>
namespace sprout {
namespace tuples {
namespace result_of {
//
// pop_back
//
template<typename Tuple>
struct pop_back
: public sprout::types::pop_back<Tuple>
{};
} // namespace result_of
namespace detail {
template<typename Result, typename Tuple, sprout::index_t... Indexes>
2012-10-06 04:53:07 +00:00
inline SPROUT_CONSTEXPR Result
pop_back_impl(Tuple const& t, sprout::index_tuple<Indexes...>) {
2012-07-18 12:44:31 +00:00
return sprout::tuples::remake<Result>(
t,
sprout::tuples::get<Indexes>(t)...
);
}
} // namespace detail
//
// pop_back
//
template<typename Tuple>
2012-10-06 04:53:07 +00:00
inline SPROUT_CONSTEXPR typename sprout::tuples::result_of::pop_back<Tuple>::type
pop_back(Tuple const& t) {
2012-07-18 12:44:31 +00:00
return sprout::tuples::detail::pop_back_impl<typename sprout::tuples::result_of::pop_back<Tuple>::type>(
t,
2013-03-31 06:14:10 +00:00
sprout::make_index_tuple<sprout::tuples::tuple_size<Tuple>::value - 1>::make()
2012-07-18 12:44:31 +00:00
);
}
} // namespace tuples
} // namespace sprout
#endif // #ifndef SPROUT_TUPLE_OPERATION_POP_BACK_HPP