/*============================================================================= 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_OPERATION_FIXED_ERASE_HPP #define SPROUT_OPERATION_FIXED_ERASE_HPP #include #include #include #include #include #include namespace sprout { namespace fixed { namespace result_of { // // erase // template struct erase : public sprout::container_transform_traits< Container >::template rebind_size< sprout::container_traits::static_size - 1 > { static_assert(sprout::container_traits::static_size >= 1, "static_size >= 1"); }; } // namespace result_of namespace detail { template inline SPROUT_CONSTEXPR Result erase_impl( Container const& cont, sprout::index_tuple, typename sprout::container_traits::difference_type pos ) { return sprout::remake( cont, sprout::size(cont) - 1, (Indexes < sprout::container_traits::static_size - 1 ? (Indexes < pos ? *sprout::next(sprout::internal_begin(cont), Indexes) : *sprout::next(sprout::internal_begin(cont), Indexes + 1) ) : typename sprout::container_traits::value_type() )... ); } } // namespace detail // // erase // template inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::erase::type erase(Container const& cont, typename sprout::container_traits::const_iterator pos) { return sprout::fixed::detail::erase_impl::type>( cont, sprout::container_indexes::type>::make(), sprout::distance(sprout::internal_begin(cont), pos) ); } // // erase // template inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::erase::type erase(Container const& cont, typename sprout::container_traits::difference_type pos) { return sprout::fixed::detail::erase_impl::type>( cont, sprout::container_indexes::type>::make(), sprout::distance(sprout::internal_begin(cont), sprout::next(sprout::begin(cont), pos)) ); } } // namespace fixed namespace result_of { using sprout::fixed::result_of::erase; } // namespace result_of using sprout::fixed::erase; } // namespace sprout #endif // #ifndef SPROUT_OPERATION_FIXED_ERASE_HPP