diff --git a/sprout/LICENSE_1_0.txt b/sprout/LICENSE_1_0.txt new file mode 100644 index 00000000..1dad8e93 --- /dev/null +++ b/sprout/LICENSE_1_0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/sprout/README b/sprout/README new file mode 100644 index 00000000..2fd26e48 --- /dev/null +++ b/sprout/README @@ -0,0 +1,51 @@ +Sprout C++ Library + +C++11 constexpr based Mutating-Algorithms and Container-Operations + +このライブラリは、C++11 の constexpr に対応した、固定長コンテナに対する STL ライクな変更のアルゴリズムやコンテナ操作を提供する。 + + + +インストール + + を参照できるようライブラリのディレクトリにパスを通す。 +このライブラリはヘッダオンリーで使える。 + + + +コンフィグ用マクロ定義 + +#define SPROUT_CONFIG_DISABLE_CONSTEXPR +このマクロが定義されているとき、関数は constexpr として宣言されない。 +コンパイラが constexpr に対応していない場合。 + +#define SPROUT_CONFIG_DISABLE_NOEXCEPT +このマクロが定義されているとき、関数は noexcept 修飾されない。 +コンパイラが noexcept に対応していない場合。 + +#define SPROUT_CONFIG_USE_SSCRISK_CEL +このマクロが定義されているとき、実装の詳細として CEL - ConstExpr Library を使用する。 +https://github.com/sscrisk/CEL---ConstExpr-Library + +これらのマクロが定義される時点は、このライブラリのいかなるヘッダがインクルードされるより以前でなければならない。 + + + +作者 + +Bolero MURAKAMI +Blog: http://d.hatena.ne.jp/boleros/ +Twitter: http://twitter.com/#!/bolero_MURAKAMI +Mail: contact-lib@boleros.x0.com + + + +著作権等 + +このライブラリは Boost Software License の元で公開されています。 + +Copyright (C) 2011 Bolero MURAKAMI. + +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) diff --git a/sprout/sprout/adapt/sscrisk/cel/array.hpp b/sprout/sprout/adapt/sscrisk/cel/array.hpp new file mode 100644 index 00000000..199dc515 --- /dev/null +++ b/sprout/sprout/adapt/sscrisk/cel/array.hpp @@ -0,0 +1,24 @@ +#ifndef SPROUT_ADAPT_SSCRISK_CEL_ARRAY_HPP +#define SPROUT_ADAPT_SSCRISK_CEL_ARRAY_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // rebind_fixed_size + // + template + struct rebind_fixed_size > { + public: + template >::size_type S> + struct apply { + public: + typedef sscrisk::cel::array type; + }; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_ADAPT_SSCRISK_CEL_ARRAY_HPP diff --git a/sprout/sprout/algorithm.hpp b/sprout/sprout/algorithm.hpp new file mode 100644 index 00000000..2259e3ab --- /dev/null +++ b/sprout/sprout/algorithm.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_HPP +#define SPROUT_ALGORITHM_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_HPP diff --git a/sprout/sprout/algorithm/copy.hpp b/sprout/sprout/algorithm/copy.hpp new file mode 100644 index 00000000..c1d3110d --- /dev/null +++ b/sprout/sprout/algorithm/copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_COPY_HPP +#define SPROUT_ALGORITHM_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_COPY_HPP diff --git a/sprout/sprout/algorithm/copy_backward.hpp b/sprout/sprout/algorithm/copy_backward.hpp new file mode 100644 index 00000000..8333b5ce --- /dev/null +++ b/sprout/sprout/algorithm/copy_backward.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_COPY_BACKWARD_HPP +#define SPROUT_ALGORITHM_COPY_BACKWARD_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_COPY_BACKWARD_HPP diff --git a/sprout/sprout/algorithm/copy_if.hpp b/sprout/sprout/algorithm/copy_if.hpp new file mode 100644 index 00000000..69da1ee4 --- /dev/null +++ b/sprout/sprout/algorithm/copy_if.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_COPY_IF_HPP +#define SPROUT_ALGORITHM_COPY_IF_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_COPY_IF_HPP diff --git a/sprout/sprout/algorithm/copy_n.hpp b/sprout/sprout/algorithm/copy_n.hpp new file mode 100644 index 00000000..88edc71d --- /dev/null +++ b/sprout/sprout/algorithm/copy_n.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_COPY_N_HPP +#define SPROUT_ALGORITHM_COPY_N_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_COPY_N_HPP diff --git a/sprout/sprout/algorithm/fill.hpp b/sprout/sprout/algorithm/fill.hpp new file mode 100644 index 00000000..41d372ed --- /dev/null +++ b/sprout/sprout/algorithm/fill.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_FILL_HPP +#define SPROUT_ALGORITHM_FILL_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_FILL_HPP diff --git a/sprout/sprout/algorithm/fill_n.hpp b/sprout/sprout/algorithm/fill_n.hpp new file mode 100644 index 00000000..512b328e --- /dev/null +++ b/sprout/sprout/algorithm/fill_n.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_FILL_N_HPP +#define SPROUT_ALGORITHM_FILL_N_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_FILL_N_HPP diff --git a/sprout/sprout/algorithm/fit.hpp b/sprout/sprout/algorithm/fit.hpp new file mode 100644 index 00000000..25507e55 --- /dev/null +++ b/sprout/sprout/algorithm/fit.hpp @@ -0,0 +1,50 @@ +#ifndef SPROUT_ALGORITHM_FIT_HPP +#define SPROUT_ALGORITHM_FIT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_FIT_HPP diff --git a/sprout/sprout/algorithm/fit/copy.hpp b/sprout/sprout/algorithm/fit/copy.hpp new file mode 100644 index 00000000..3b52a064 --- /dev/null +++ b/sprout/sprout/algorithm/fit/copy.hpp @@ -0,0 +1,46 @@ +#ifndef SPROUT_ALGORITHM_FIT_COPY_HPP +#define SPROUT_ALGORITHM_FIT_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type copy_impl( + Iterator first, + Iterator last, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::copy(first, last, result)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last), sprout::size(result)) + ); + } + } // namespace detail + // + // copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type copy( + Iterator first, + Iterator last, + Result const& result + ) + { + return sprout::fit::detail::copy_impl(first, last, result, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_COPY_HPP diff --git a/sprout/sprout/algorithm/fit/copy_backward.hpp b/sprout/sprout/algorithm/fit/copy_backward.hpp new file mode 100644 index 00000000..a046f374 --- /dev/null +++ b/sprout/sprout/algorithm/fit/copy_backward.hpp @@ -0,0 +1,46 @@ +#ifndef SPROUT_ALGORITHM_FIT_COPY_BACKWARD_HPP +#define SPROUT_ALGORITHM_FIT_COPY_BACKWARD_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type copy_backward_impl( + Iterator first, + Iterator last, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::copy_backward(first, last, result)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last), sprout::size(result)) + ); + } + } // namespace detail + // + // copy_backward + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type copy_backward( + Iterator first, + Iterator last, + Result const& result + ) + { + return sprout::fit::detail::copy_backward_impl(first, last, result, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_COPY_BACKWARD_HPP diff --git a/sprout/sprout/algorithm/fit/copy_if.hpp b/sprout/sprout/algorithm/fit/copy_if.hpp new file mode 100644 index 00000000..207aaa43 --- /dev/null +++ b/sprout/sprout/algorithm/fit/copy_if.hpp @@ -0,0 +1,47 @@ +#ifndef SPROUT_ALGORITHM_FIT_COPY_IF_HPP +#define SPROUT_ALGORITHM_FIT_COPY_IF_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type copy_if_impl( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::copy_if(first, last, result, pred)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::count_if(first, last, pred), sprout::size(result)) + ); + } + } // namespace detail + // + // copy_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type copy_if( + Iterator first, + Iterator last, + Result const& result, + Predicate pred + ) + { + return sprout::fit::detail::copy_if_impl(first, last, result, pred, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_COPY_IF_HPP diff --git a/sprout/sprout/algorithm/fit/copy_n.hpp b/sprout/sprout/algorithm/fit/copy_n.hpp new file mode 100644 index 00000000..e3bec4e7 --- /dev/null +++ b/sprout/sprout/algorithm/fit/copy_n.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_ALGORITHM_FIT_COPY_N_HPP +#define SPROUT_ALGORITHM_FIT_COPY_N_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type copy_n_impl( + Iterator first, + Size n, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::copy_n(first, n, result)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(n, sprout::size(result)) + ); + } + } // namespace detail + // + // copy_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type copy_n( + Iterator first, + Size n, + Result const& result + ) + { + return sprout::fit::detail::copy_n_impl(first, n, result, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_COPY_N_HPP diff --git a/sprout/sprout/algorithm/fit/fill.hpp b/sprout/sprout/algorithm/fit/fill.hpp new file mode 100644 index 00000000..37858feb --- /dev/null +++ b/sprout/sprout/algorithm/fit/fill.hpp @@ -0,0 +1,42 @@ +#ifndef SPROUT_ALGORITHM_FIT_FILL_HPP +#define SPROUT_ALGORITHM_FIT_FILL_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type fill_impl( + Container const& cont, + T const& value, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::fill(cont, value)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // fill + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type fill( + Container const& cont, + T const& value + ) + { + return sprout::fit::detail::fill_impl(cont, value, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_FILL_HPP diff --git a/sprout/sprout/algorithm/fit/fill_n.hpp b/sprout/sprout/algorithm/fit/fill_n.hpp new file mode 100644 index 00000000..9ed1bfa5 --- /dev/null +++ b/sprout/sprout/algorithm/fit/fill_n.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_ALGORITHM_FIT_FILL_N_HPP +#define SPROUT_ALGORITHM_FIT_FILL_N_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type fill_n_impl( + Container const& cont, + Size n, + T const& value, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::fill_n(cont, n, value)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(n, sprout::size(cont)) + ); + } + } // namespace detail + // + // fill_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type fill_n( + Container const& cont, + Size n, + T const& value + ) + { + return sprout::fit::detail::fill_n_impl(cont, n, value, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_FILL_N_HPP diff --git a/sprout/sprout/algorithm/fit/generate.hpp b/sprout/sprout/algorithm/fit/generate.hpp new file mode 100644 index 00000000..016f4bfe --- /dev/null +++ b/sprout/sprout/algorithm/fit/generate.hpp @@ -0,0 +1,44 @@ +#ifndef SPROUT_ALGORITHM_FIT_GENERATE_HPP +#define SPROUT_ALGORITHM_FIT_GENERATE_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type generate_impl( + Container const& cont, + Generator gen, + typename sprout::fixed_container_traits::difference_type offset, + Inits const&... inits + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::generate(cont, gen, inits...)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // generate + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type generate( + Container const& cont, + Generator gen, + Inits const&... inits + ) + { + return sprout::fit::detail::generate_impl(cont, gen, sprout::fixed_begin_offset(cont), inits...); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_GENERATE_HPP diff --git a/sprout/sprout/algorithm/fit/generate_n.hpp b/sprout/sprout/algorithm/fit/generate_n.hpp new file mode 100644 index 00000000..4792784d --- /dev/null +++ b/sprout/sprout/algorithm/fit/generate_n.hpp @@ -0,0 +1,47 @@ +#ifndef SPROUT_ALGORITHM_FIT_GENERATE_N_HPP +#define SPROUT_ALGORITHM_FIT_GENERATE_N_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type generate_n_impl( + Container const& cont, + Size n, + Generator gen, + typename sprout::fixed_container_traits::difference_type offset, + Inits const&... inits + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::generate_n(cont, n, gen, inits...)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(n, sprout::size(cont)) + ); + } + } // namespace detail + // + // generate_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type generate_n( + Container const& cont, + Size n, + Generator gen, + Inits const&... inits + ) + { + return sprout::fit::detail::generate_n_impl(cont, n, gen, sprout::fixed_begin_offset(cont), inits...); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_GENERATE_N_HPP diff --git a/sprout/sprout/algorithm/fit/inplace_merge.hpp b/sprout/sprout/algorithm/fit/inplace_merge.hpp new file mode 100644 index 00000000..2bff81bf --- /dev/null +++ b/sprout/sprout/algorithm/fit/inplace_merge.hpp @@ -0,0 +1,71 @@ +#ifndef SPROUT_ALGORITHM_FIT_INPLACE_MERGE_HPP +#define SPROUT_ALGORITHM_FIT_INPLACE_MERGE_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type inplace_merge_impl( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::inplace_merge(cont, middle, comp)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // inplace_merge + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type inplace_merge( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + Compare comp + ) + { + return sprout::fit::detail::inplace_merge_impl(cont, middle, comp, sprout::fixed_begin_offset(cont)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type inplace_merge_impl( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::inplace_merge(cont, middle)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // inplace_merge + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type inplace_merge( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle + ) + { + return sprout::fit::detail::inplace_merge_impl(cont, middle, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_INPLACE_MERGE_HPP diff --git a/sprout/sprout/algorithm/fit/make_heap.hpp b/sprout/sprout/algorithm/fit/make_heap.hpp new file mode 100644 index 00000000..050acdf6 --- /dev/null +++ b/sprout/sprout/algorithm/fit/make_heap.hpp @@ -0,0 +1,67 @@ +#ifndef SPROUT_ALGORITHM_FIT_MAKE_HEAP_HPP +#define SPROUT_ALGORITHM_FIT_MAKE_HEAP_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type make_heap_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::make_heap(cont, comp)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // make_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type make_heap( + Container const& cont, + Compare comp + ) + { + return sprout::fit::detail::make_heap_impl(cont, comp, sprout::fixed_begin_offset(cont)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type make_heap_impl( + Container const& cont, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::make_heap(cont)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // make_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type make_heap( + Container const& cont + ) + { + return sprout::fit::detail::make_heap_impl(cont, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_MAKE_HEAP_HPP diff --git a/sprout/sprout/algorithm/fit/make_partial_heap.hpp b/sprout/sprout/algorithm/fit/make_partial_heap.hpp new file mode 100644 index 00000000..70118993 --- /dev/null +++ b/sprout/sprout/algorithm/fit/make_partial_heap.hpp @@ -0,0 +1,72 @@ +#ifndef SPROUT_ALGORITHM_FIT_MAKE_PARTIAL_HEAP_HPP +#define SPROUT_ALGORITHM_FIT_MAKE_PARTIAL_HEAP_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type make_partial_heap_impl( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::make_partial_heap(cont, middle, comp)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), middle) + ); + } + } // namespace detail + // + // make_partial_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type make_partial_heap( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + Compare comp + ) + { + return sprout::fit::detail::make_partial_heap_impl(cont, middle, comp, sprout::fixed_begin_offset(cont)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type make_partial_heap_impl( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::make_partial_heap(cont, middle)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), middle) + ); + } + } // namespace detail + // + // make_partial_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type make_partial_heap( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle + ) + { + return sprout::fit::detail::make_partial_heap_impl(cont, middle, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_MAKE_PARTIAL_HEAP_HPP diff --git a/sprout/sprout/algorithm/fit/merge.hpp b/sprout/sprout/algorithm/fit/merge.hpp new file mode 100644 index 00000000..d3f08cd1 --- /dev/null +++ b/sprout/sprout/algorithm/fit/merge.hpp @@ -0,0 +1,91 @@ +#ifndef SPROUT_ALGORITHM_FIT_MERGE_HPP +#define SPROUT_ALGORITHM_FIT_MERGE_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type merge_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::merge(first1, last1, first2, last2, result, comp)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min( + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first1, last1) + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first2, last2), + sprout::size(result) + ) + ); + } + } // namespace detail + // + // merge + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type merge( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return sprout::fit::detail::merge_impl(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type merge_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::merge(first1, last1, first2, last2, result)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min( + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first1, last1) + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first2, last2), + sprout::size(result) + ) + ); + } + } // namespace detail + // + // merge + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type merge( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result + ) + { + return sprout::fit::detail::merge_impl(first1, last1, first2, last2, result, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_MERGE_HPP diff --git a/sprout/sprout/algorithm/fit/nth_element.hpp b/sprout/sprout/algorithm/fit/nth_element.hpp new file mode 100644 index 00000000..a1cc6694 --- /dev/null +++ b/sprout/sprout/algorithm/fit/nth_element.hpp @@ -0,0 +1,72 @@ +#ifndef SPROUT_ALGORITHM_FIT_NTH_ELEMENT_HPP +#define SPROUT_ALGORITHM_FIT_NTH_ELEMENT_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type nth_element_impl( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator nth, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::nth_element(cont, nth, comp)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), nth) + 1 + ); + } + } // namespace detail + // + // nth_element + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type nth_element( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator nth, + Compare comp + ) + { + return sprout::fit::detail::nth_element_impl(cont, nth, comp, sprout::fixed_begin_offset(cont)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type nth_element_impl( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator nth, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::nth_element(cont, nth)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), nth) + 1 + ); + } + } // namespace detail + // + // nth_element + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type nth_element( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator nth + ) + { + return sprout::fit::detail::nth_element_impl(cont, nth, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_NTH_ELEMENT_HPP diff --git a/sprout/sprout/algorithm/fit/partial_sort.hpp b/sprout/sprout/algorithm/fit/partial_sort.hpp new file mode 100644 index 00000000..fae1aef2 --- /dev/null +++ b/sprout/sprout/algorithm/fit/partial_sort.hpp @@ -0,0 +1,72 @@ +#ifndef SPROUT_ALGORITHM_FIT_PARTIAL_SORT_HPP +#define SPROUT_ALGORITHM_FIT_PARTIAL_SORT_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type partial_sort_impl( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::partial_sort(cont, middle, comp)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), middle) + ); + } + } // namespace detail + // + // partial_sort + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type partial_sort( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + Compare comp + ) + { + return sprout::fit::detail::partial_sort_impl(cont, middle, comp, sprout::fixed_begin_offset(cont)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type partial_sort_impl( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::partial_sort(cont, middle)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), middle) + ); + } + } // namespace detail + // + // partial_sort + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type partial_sort( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle + ) + { + return sprout::fit::detail::partial_sort_impl(cont, middle, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_PARTIAL_SORT_HPP diff --git a/sprout/sprout/algorithm/fit/partition.hpp b/sprout/sprout/algorithm/fit/partition.hpp new file mode 100644 index 00000000..87d7b795 --- /dev/null +++ b/sprout/sprout/algorithm/fit/partition.hpp @@ -0,0 +1,43 @@ +#ifndef SPROUT_ALGORITHM_FIT_PARTITION_HPP +#define SPROUT_ALGORITHM_FIT_PARTITION_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type partition_impl( + Container const& cont, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::partition(cont, pred)), + offset, + offset + sprout::size(cont) - NS_SSCRISK_CEL_OR_SPROUT_DETAIL::count_if(sprout::begin(cont), sprout::end(cont), pred) + ); + } + } // namespace detail + // + // partition + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type partition( + Container const& cont, + Predicate pred + ) + { + return sprout::fit::detail::partition_impl(cont, pred, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_PARTITION_HPP diff --git a/sprout/sprout/algorithm/fit/partition_copy.hpp b/sprout/sprout/algorithm/fit/partition_copy.hpp new file mode 100644 index 00000000..56122dde --- /dev/null +++ b/sprout/sprout/algorithm/fit/partition_copy.hpp @@ -0,0 +1,47 @@ +#ifndef SPROUT_ALGORITHM_FIT_PARTITION_COPY_HPP +#define SPROUT_ALGORITHM_FIT_PARTITION_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type partition_copy_impl( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::partition_copy(first, last, result, pred)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::count_if(first, last, pred), sprout::size(result)) + ); + } + } // namespace detail + // + // partition_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type partition_copy( + Iterator first, + Iterator last, + Result const& result, + Predicate pred + ) + { + return sprout::fit::detail::partition_copy_impl(first, last, result, pred, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_PARTITION_COPY_HPP diff --git a/sprout/sprout/algorithm/fit/pop_heap.hpp b/sprout/sprout/algorithm/fit/pop_heap.hpp new file mode 100644 index 00000000..b8eb802a --- /dev/null +++ b/sprout/sprout/algorithm/fit/pop_heap.hpp @@ -0,0 +1,67 @@ +#ifndef SPROUT_ALGORITHM_FIT_POP_HEAP_HPP +#define SPROUT_ALGORITHM_FIT_POP_HEAP_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type pop_heap_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::pop_heap(cont, comp)), + offset, + offset + sprout::size(cont) - 1 + ); + } + } // namespace detail + // + // pop_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type pop_heap( + Container const& cont, + Compare comp + ) + { + return sprout::fit::detail::pop_heap_impl(cont, comp, sprout::fixed_begin_offset(cont)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type pop_heap_impl( + Container const& cont, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::pop_heap(cont)), + offset, + offset + sprout::size(cont) - 1 + ); + } + } // namespace detail + // + // pop_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type pop_heap( + Container const& cont + ) + { + return sprout::fit::detail::pop_heap_impl(cont, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_POP_HEAP_HPP diff --git a/sprout/sprout/algorithm/fit/push_heap.hpp b/sprout/sprout/algorithm/fit/push_heap.hpp new file mode 100644 index 00000000..197b62b8 --- /dev/null +++ b/sprout/sprout/algorithm/fit/push_heap.hpp @@ -0,0 +1,67 @@ +#ifndef SPROUT_ALGORITHM_FIT_PUSH_HEAP_HPP +#define SPROUT_ALGORITHM_FIT_PUSH_HEAP_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type push_heap_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::push_heap(cont, comp)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // push_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type push_heap( + Container const& cont, + Compare comp + ) + { + return sprout::fit::detail::push_heap_impl(cont, comp, sprout::fixed_begin_offset(cont)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type push_heap_impl( + Container const& cont, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::push_heap(cont)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // push_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type push_heap( + Container const& cont + ) + { + return sprout::fit::detail::push_heap_impl(cont, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_PUSH_HEAP_HPP diff --git a/sprout/sprout/algorithm/fit/remove.hpp b/sprout/sprout/algorithm/fit/remove.hpp new file mode 100644 index 00000000..a81870c9 --- /dev/null +++ b/sprout/sprout/algorithm/fit/remove.hpp @@ -0,0 +1,43 @@ +#ifndef SPROUT_ALGORITHM_FIT_REMOVE_HPP +#define SPROUT_ALGORITHM_FIT_REMOVE_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type remove_impl( + Container const& cont, + T const& value, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::remove(cont, value)), + offset, + offset + sprout::size(cont) - NS_SSCRISK_CEL_OR_SPROUT_DETAIL::count(sprout::begin(cont), sprout::end(cont), value) + ); + } + } // namespace detail + // + // remove + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type remove( + Container const& cont, + T const& value + ) + { + return sprout::fit::detail::remove_impl(cont, value, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_REMOVE_HPP diff --git a/sprout/sprout/algorithm/fit/remove_copy.hpp b/sprout/sprout/algorithm/fit/remove_copy.hpp new file mode 100644 index 00000000..1dc99db9 --- /dev/null +++ b/sprout/sprout/algorithm/fit/remove_copy.hpp @@ -0,0 +1,48 @@ +#ifndef SPROUT_ALGORITHM_FIT_REMOVE_COPY_HPP +#define SPROUT_ALGORITHM_FIT_REMOVE_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type remove_copy_impl( + Iterator first, + Iterator last, + Result const& result, + T const& value, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::remove_copy(first, last, result, value)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last) - NS_SSCRISK_CEL_OR_SPROUT_DETAIL::count(first, last, value), sprout::size(result)) + ); + } + } // namespace detail + // + // remove_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type remove_copy( + Iterator first, + Iterator last, + Result const& result, + T const& value + ) + { + return sprout::fit::detail::remove_copy_impl(first, last, result, value, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_REMOVE_COPY_HPP diff --git a/sprout/sprout/algorithm/fit/remove_copy_if.hpp b/sprout/sprout/algorithm/fit/remove_copy_if.hpp new file mode 100644 index 00000000..ba868242 --- /dev/null +++ b/sprout/sprout/algorithm/fit/remove_copy_if.hpp @@ -0,0 +1,48 @@ +#ifndef SPROUT_ALGORITHM_FIT_REMOVE_COPY_IF_HPP +#define SPROUT_ALGORITHM_FIT_REMOVE_COPY_IF_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type remove_copy_if_impl( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::remove_copy_if(first, last, result, pred)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last) - NS_SSCRISK_CEL_OR_SPROUT_DETAIL::count_if(first, last, pred), sprout::size(result)) + ); + } + } // namespace detail + // + // remove_copy_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type remove_copy_if( + Iterator first, + Iterator last, + Result const& result, + Predicate pred + ) + { + return sprout::fit::detail::remove_copy_if_impl(first, last, result, pred, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_REMOVE_COPY_IF_HPP diff --git a/sprout/sprout/algorithm/fit/remove_if.hpp b/sprout/sprout/algorithm/fit/remove_if.hpp new file mode 100644 index 00000000..2eecfea1 --- /dev/null +++ b/sprout/sprout/algorithm/fit/remove_if.hpp @@ -0,0 +1,43 @@ +#ifndef SPROUT_ALGORITHM_FIT_REMOVE_IF_HPP +#define SPROUT_ALGORITHM_FIT_REMOVE_IF_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type remove_if_impl( + Container const& cont, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::remove_if(cont, pred)), + offset, + offset + sprout::size(cont) - NS_SSCRISK_CEL_OR_SPROUT_DETAIL::count_if(sprout::begin(cont), sprout::end(cont), pred) + ); + } + } // namespace detail + // + // remove_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type remove_if( + Container const& cont, + Predicate pred + ) + { + return sprout::fit::detail::remove_if_impl(cont, pred, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_REMOVE_IF_HPP diff --git a/sprout/sprout/algorithm/fit/replace.hpp b/sprout/sprout/algorithm/fit/replace.hpp new file mode 100644 index 00000000..bb2a22fd --- /dev/null +++ b/sprout/sprout/algorithm/fit/replace.hpp @@ -0,0 +1,44 @@ +#ifndef SPROUT_ALGORITHM_FIT_REPLACE_HPP +#define SPROUT_ALGORITHM_FIT_REPLACE_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type replace_impl( + Container const& cont, + T const& old_value, + T const& new_value, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::replace(cont, old_value, new_value)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // replace + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type replace( + Container const& cont, + T const& old_value, + T const& new_value + ) + { + return sprout::fit::detail::replace_impl(cont, old_value, new_value, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_REPLACE_HPP diff --git a/sprout/sprout/algorithm/fit/replace_copy.hpp b/sprout/sprout/algorithm/fit/replace_copy.hpp new file mode 100644 index 00000000..ff8a68e2 --- /dev/null +++ b/sprout/sprout/algorithm/fit/replace_copy.hpp @@ -0,0 +1,50 @@ +#ifndef SPROUT_ALGORITHM_FIT_REPLACE_COPY_HPP +#define SPROUT_ALGORITHM_FIT_REPLACE_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type replace_copy_impl( + Iterator first, + Iterator last, + Result const& result, + T const& old_value, + T const& new_value, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::replace_copy(first, last, result, old_value, new_value)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last), sprout::size(result)) + ); + } + } // namespace detail + // + // replace_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type replace_copy( + Iterator first, + Iterator last, + Result const& result, + T const& old_value, + T const& new_value + ) + { + return sprout::fit::detail::replace_copy_impl(first, last, result, old_value, new_value, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_REPLACE_COPY_HPP diff --git a/sprout/sprout/algorithm/fit/replace_copy_if.hpp b/sprout/sprout/algorithm/fit/replace_copy_if.hpp new file mode 100644 index 00000000..0e6fecd6 --- /dev/null +++ b/sprout/sprout/algorithm/fit/replace_copy_if.hpp @@ -0,0 +1,50 @@ +#ifndef SPROUT_ALGORITHM_FIT_REPLACE_COPY_IF_HPP +#define SPROUT_ALGORITHM_FIT_REPLACE_COPY_IF_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type replace_copy_if_impl( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + T const& new_value, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::replace_copy_if(first, last, result, pred, new_value)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last), sprout::size(result)) + ); + } + } // namespace detail + // + // replace_copy_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type replace_copy_if( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + T const& new_value + ) + { + return sprout::fit::detail::replace_copy_if_impl(first, last, result, pred, new_value, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_REPLACE_COPY_IF_HPP diff --git a/sprout/sprout/algorithm/fit/replace_if.hpp b/sprout/sprout/algorithm/fit/replace_if.hpp new file mode 100644 index 00000000..ba957841 --- /dev/null +++ b/sprout/sprout/algorithm/fit/replace_if.hpp @@ -0,0 +1,44 @@ +#ifndef SPROUT_ALGORITHM_FIT_REPLACE_IF_HPP +#define SPROUT_ALGORITHM_FIT_REPLACE_IF_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type replace_if_impl( + Container const& cont, + Predicate pred, + T const& new_value, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::replace_if(cont, pred, new_value)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // replace_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type replace_if( + Container const& cont, + Predicate pred, + T const& new_value + ) + { + return sprout::fit::detail::replace_if_impl(cont, pred, new_value, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_REPLACE_IF_HPP diff --git a/sprout/sprout/algorithm/fit/result_of.hpp b/sprout/sprout/algorithm/fit/result_of.hpp new file mode 100644 index 00000000..23461747 --- /dev/null +++ b/sprout/sprout/algorithm/fit/result_of.hpp @@ -0,0 +1,27 @@ +#ifndef SPROUT_ALGORITHM_FIT_RESULT_OF_HPP +#define SPROUT_ALGORITHM_FIT_RESULT_OF_HPP + +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // algorithm + // + template + struct algorithm { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::algorithm::type + >::internal_type + > type; + }; + } // namespace result_of + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_RESULT_OF_HPP diff --git a/sprout/sprout/algorithm/fit/reverse.hpp b/sprout/sprout/algorithm/fit/reverse.hpp new file mode 100644 index 00000000..6a75481e --- /dev/null +++ b/sprout/sprout/algorithm/fit/reverse.hpp @@ -0,0 +1,40 @@ +#ifndef SPROUT_ALGORITHM_FIT_REVERSE_HPP +#define SPROUT_ALGORITHM_FIT_REVERSE_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type reverse_impl( + Container const& cont, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::reverse(cont)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // reverse + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type reverse( + Container const& cont + ) + { + return sprout::fit::detail::reverse_impl(cont, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_REVERSE_HPP diff --git a/sprout/sprout/algorithm/fit/reverse_copy.hpp b/sprout/sprout/algorithm/fit/reverse_copy.hpp new file mode 100644 index 00000000..8b93b6b6 --- /dev/null +++ b/sprout/sprout/algorithm/fit/reverse_copy.hpp @@ -0,0 +1,46 @@ +#ifndef SPROUT_ALGORITHM_FIT_REVERSE_COPY_HPP +#define SPROUT_ALGORITHM_FIT_REVERSE_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type reverse_copy_impl( + Iterator first, + Iterator last, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::reverse_copy(first, last, result)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last), sprout::size(result)) + ); + } + } // namespace detail + // + // reverse_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type reverse_copy( + Iterator first, + Iterator last, + Result const& result + ) + { + return sprout::fit::detail::reverse_copy_impl(first, last, result, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_REVERSE_COPY_HPP diff --git a/sprout/sprout/algorithm/fit/rotate.hpp b/sprout/sprout/algorithm/fit/rotate.hpp new file mode 100644 index 00000000..0b0c8d56 --- /dev/null +++ b/sprout/sprout/algorithm/fit/rotate.hpp @@ -0,0 +1,42 @@ +#ifndef SPROUT_ALGORITHM_FIT_ROTATE_HPP +#define SPROUT_ALGORITHM_FIT_ROTATE_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type rotate_impl( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::rotate(cont, middle)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // rotate + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type rotate( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle + ) + { + return sprout::fit::detail::rotate_impl(cont, middle, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_ROTATE_HPP diff --git a/sprout/sprout/algorithm/fit/rotate_copy.hpp b/sprout/sprout/algorithm/fit/rotate_copy.hpp new file mode 100644 index 00000000..99ed4d5e --- /dev/null +++ b/sprout/sprout/algorithm/fit/rotate_copy.hpp @@ -0,0 +1,48 @@ +#ifndef SPROUT_ALGORITHM_FIT_ROTATE_COPY_HPP +#define SPROUT_ALGORITHM_FIT_ROTATE_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type rotate_copy_impl( + Iterator first, + Iterator middle, + Iterator last, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::rotate_copy(first, middle, last, result)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last), sprout::size(result)) + ); + } + } // namespace detail + // + // rotate_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type rotate_copy( + Iterator first, + Iterator middle, + Iterator last, + Result const& result + ) + { + return sprout::fit::detail::rotate_copy_impl(first, middle, last, result, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_ROTATE_COPY_HPP diff --git a/sprout/sprout/algorithm/fit/set_difference.hpp b/sprout/sprout/algorithm/fit/set_difference.hpp new file mode 100644 index 00000000..a601b5fa --- /dev/null +++ b/sprout/sprout/algorithm/fit/set_difference.hpp @@ -0,0 +1,96 @@ +#ifndef SPROUT_ALGORITHM_FIT_SET_DIFFERENCE_HPP +#define SPROUT_ALGORITHM_FIT_SET_DIFFERENCE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_difference_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::set_difference(first1, last1, first2, last2, result, comp)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min( + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first1, last1) + - sprout::detail::overlap_count_2(first1, last1, first2, last2, comp) + , + sprout::size(result) + ) + ); + } + } // namespace detail + // + // set_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_difference( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return sprout::fit::detail::set_difference_impl(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_difference_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::set_difference(first1, last1, first2, last2, result)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min( + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first1, last1) + - sprout::detail::overlap_count_2(first1, last1, first2, last2) + , + sprout::size(result) + ) + ); + } + } // namespace detail + // + // set_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_difference( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result + ) + { + return sprout::fit::detail::set_difference_impl(first1, last1, first2, last2, result, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_SET_DIFFERENCE_HPP diff --git a/sprout/sprout/algorithm/fit/set_intersection.hpp b/sprout/sprout/algorithm/fit/set_intersection.hpp new file mode 100644 index 00000000..94152fc9 --- /dev/null +++ b/sprout/sprout/algorithm/fit/set_intersection.hpp @@ -0,0 +1,91 @@ +#ifndef SPROUT_ALGORITHM_FIT_SET_INTERSECTION_HPP +#define SPROUT_ALGORITHM_FIT_SET_INTERSECTION_HPP + +#include +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_intersection_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::set_intersection(first1, last1, first2, last2, result, comp)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min( + sprout::detail::overlap_count_2(first1, last1, first2, last2, comp), + sprout::size(result) + ) + ); + } + } // namespace detail + // + // set_intersection + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_intersection( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return sprout::fit::detail::set_intersection_impl(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_intersection_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::set_intersection(first1, last1, first2, last2, result)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min( + sprout::detail::overlap_count_2(first1, last1, first2, last2), + sprout::size(result) + ) + ); + } + } // namespace detail + // + // set_intersection + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_intersection( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result + ) + { + return sprout::fit::detail::set_intersection_impl(first1, last1, first2, last2, result, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_SET_INTERSECTION_HPP diff --git a/sprout/sprout/algorithm/fit/set_symmetric_difference.hpp b/sprout/sprout/algorithm/fit/set_symmetric_difference.hpp new file mode 100644 index 00000000..7c9a2b5d --- /dev/null +++ b/sprout/sprout/algorithm/fit/set_symmetric_difference.hpp @@ -0,0 +1,98 @@ +#ifndef SPROUT_ALGORITHM_FIT_SET_SYMMETRIC_DIFFERENCE_HPP +#define SPROUT_ALGORITHM_FIT_SET_SYMMETRIC_DIFFERENCE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_symmetric_difference_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::set_symmetric_difference(first1, last1, first2, last2, result, comp)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min( + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first1, last1) + + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first2, last2) + - 2 * sprout::detail::overlap_count_2(first1, last1, first2, last2, comp) + , + sprout::size(result) + ) + ); + } + } // namespace detail + // + // set_symmetric_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_symmetric_difference( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return sprout::fit::detail::set_symmetric_difference_impl(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_symmetric_difference_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::set_symmetric_difference(first1, last1, first2, last2, result)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min( + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first1, last1) + + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first2, last2) + - 2 * sprout::detail::overlap_count_2(first1, last1, first2, last2) + , + sprout::size(result) + ) + ); + } + } // namespace detail + // + // set_symmetric_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_symmetric_difference( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result + ) + { + return sprout::fit::detail::set_symmetric_difference_impl(first1, last1, first2, last2, result, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_SET_SYMMETRIC_DIFFERENCE_HPP diff --git a/sprout/sprout/algorithm/fit/set_union.hpp b/sprout/sprout/algorithm/fit/set_union.hpp new file mode 100644 index 00000000..113716bc --- /dev/null +++ b/sprout/sprout/algorithm/fit/set_union.hpp @@ -0,0 +1,98 @@ +#ifndef SPROUT_ALGORITHM_FIT_SET_UNION_HPP +#define SPROUT_ALGORITHM_FIT_SET_UNION_HPP + +#include +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_union_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::set_union(first1, last1, first2, last2, result, comp)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min( + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first1, last1) + + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first2, last2) + - sprout::detail::overlap_count_2(first1, last1, first2, last2, comp) + , + sprout::size(result) + ) + ); + } + } // namespace detail + // + // set_union + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_union( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return sprout::fit::detail::set_union_impl(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_union_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::set_union(first1, last1, first2, last2, result)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min( + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first1, last1) + + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first2, last2) + - sprout::detail::overlap_count_2(first1, last1, first2, last2) + , + sprout::size(result) + ) + ); + } + } // namespace detail + // + // set_union + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type set_union( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result + ) + { + return sprout::fit::detail::set_union_impl(first1, last1, first2, last2, result, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_SET_UNION_HPP diff --git a/sprout/sprout/algorithm/fit/sort.hpp b/sprout/sprout/algorithm/fit/sort.hpp new file mode 100644 index 00000000..302cf8e0 --- /dev/null +++ b/sprout/sprout/algorithm/fit/sort.hpp @@ -0,0 +1,67 @@ +#ifndef SPROUT_ALGORITHM_FIT_SORT_HPP +#define SPROUT_ALGORITHM_FIT_SORT_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type sort_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::sort(cont, comp)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // sort + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type sort( + Container const& cont, + Compare comp + ) + { + return sprout::fit::detail::sort_impl(cont, comp, sprout::fixed_begin_offset(cont)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type sort_impl( + Container const& cont, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::sort(cont)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // sort + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type sort( + Container const& cont + ) + { + return sprout::fit::detail::sort_impl(cont, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_SORT_HPP diff --git a/sprout/sprout/algorithm/fit/sort_heap.hpp b/sprout/sprout/algorithm/fit/sort_heap.hpp new file mode 100644 index 00000000..eb9cc6a2 --- /dev/null +++ b/sprout/sprout/algorithm/fit/sort_heap.hpp @@ -0,0 +1,67 @@ +#ifndef SPROUT_ALGORITHM_FIT_SORT_HEAP_HPP +#define SPROUT_ALGORITHM_FIT_SORT_HEAP_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type sort_heap_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::sort_heap(cont, comp)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // sort_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type sort_heap( + Container const& cont, + Compare comp + ) + { + return sprout::fit::detail::sort_heap_impl(cont, comp, sprout::fixed_begin_offset(cont)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type sort_heap_impl( + Container const& cont, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::sort_heap(cont)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // sort_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type sort_heap( + Container const& cont + ) + { + return sprout::fit::detail::sort_heap_impl(cont, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_SORT_HEAP_HPP diff --git a/sprout/sprout/algorithm/fit/stable_partition.hpp b/sprout/sprout/algorithm/fit/stable_partition.hpp new file mode 100644 index 00000000..37816378 --- /dev/null +++ b/sprout/sprout/algorithm/fit/stable_partition.hpp @@ -0,0 +1,43 @@ +#ifndef SPROUT_ALGORITHM_FIT_STABLE_PARTITION_HPP +#define SPROUT_ALGORITHM_FIT_STABLE_PARTITION_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type stable_partition_impl( + Container const& cont, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::stable_partition(cont, pred)), + offset, + offset + sprout::size(cont) - NS_SSCRISK_CEL_OR_SPROUT_DETAIL::count_if(sprout::begin(cont), sprout::end(cont), pred) + ); + } + } // namespace detail + // + // stable_partition + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type stable_partition( + Container const& cont, + Predicate pred + ) + { + return sprout::fit::detail::stable_partition_impl(cont, pred, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_STABLE_PARTITION_HPP diff --git a/sprout/sprout/algorithm/fit/stable_partition_copy.hpp b/sprout/sprout/algorithm/fit/stable_partition_copy.hpp new file mode 100644 index 00000000..4632ac6f --- /dev/null +++ b/sprout/sprout/algorithm/fit/stable_partition_copy.hpp @@ -0,0 +1,47 @@ +#ifndef SPROUT_ALGORITHM_FIT_STABLE_PARTITION_COPY_HPP +#define SPROUT_ALGORITHM_FIT_STABLE_PARTITION_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type stable_partition_copy_impl( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::stable_partition_copy(first, last, result, pred)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::count_if(first, last, pred), sprout::size(result)) + ); + } + } // namespace detail + // + // stable_partition_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type stable_partition_copy( + Iterator first, + Iterator last, + Result const& result, + Predicate pred + ) + { + return sprout::fit::detail::stable_partition_copy_impl(first, last, result, pred, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_STABLE_PARTITION_COPY_HPP diff --git a/sprout/sprout/algorithm/fit/stable_sort.hpp b/sprout/sprout/algorithm/fit/stable_sort.hpp new file mode 100644 index 00000000..45a34391 --- /dev/null +++ b/sprout/sprout/algorithm/fit/stable_sort.hpp @@ -0,0 +1,67 @@ +#ifndef SPROUT_ALGORITHM_FIT_STABLE_SORT_HPP +#define SPROUT_ALGORITHM_FIT_STABLE_SORT_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type stable_sort_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::stable_sort(cont, comp)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // stable_sort + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type stable_sort( + Container const& cont, + Compare comp + ) + { + return sprout::fit::detail::stable_sort_impl(cont, comp, sprout::fixed_begin_offset(cont)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type stable_sort_impl( + Container const& cont, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::stable_sort(cont)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // stable_sort + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type stable_sort( + Container const& cont + ) + { + return sprout::fit::detail::stable_sort_impl(cont, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_STABLE_SORT_HPP diff --git a/sprout/sprout/algorithm/fit/swap_element.hpp b/sprout/sprout/algorithm/fit/swap_element.hpp new file mode 100644 index 00000000..97ff1698 --- /dev/null +++ b/sprout/sprout/algorithm/fit/swap_element.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_ALGORITHM_FIT_SWAP_ELEMENT_HPP +#define SPROUT_ALGORITHM_FIT_SWAP_ELEMENT_HPP + +#include +#include +#include +#include +#include +#include + + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type swap_element_impl( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos1, + typename sprout::fixed_container_traits::const_iterator pos2, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::swap_element(cont, pos1, pos2)), + offset, + offset + sprout::size(cont) + ); + } + } // namespace detail + // + // swap_element + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type swap_element( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos1, + typename sprout::fixed_container_traits::const_iterator pos2 + ) + { + return sprout::fit::detail::swap_element_impl(cont, pos1, pos2, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_SWAP_ELEMENT_HPP diff --git a/sprout/sprout/algorithm/fit/swap_element_copy.hpp b/sprout/sprout/algorithm/fit/swap_element_copy.hpp new file mode 100644 index 00000000..49276e0e --- /dev/null +++ b/sprout/sprout/algorithm/fit/swap_element_copy.hpp @@ -0,0 +1,50 @@ +#ifndef SPROUT_ALGORITHM_FIT_SWAP_ELEMENT_COPY_HPP +#define SPROUT_ALGORITHM_FIT_SWAP_ELEMENT_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type swap_element_copy_impl( + Iterator first, + Iterator last, + Result const& result, + Iterator pos1, + Iterator pos2, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::swap_element_copy(first, last, result, pos1, pos2)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last), sprout::size(result)) + ); + } + } // namespace detail + // + // swap_element_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type swap_element_copy( + Iterator first, + Iterator last, + Result const& result, + Iterator pos1, + Iterator pos2 + ) + { + return sprout::fit::detail::swap_element_copy_impl(first, last, result, pos1, pos2, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_SWAP_ELEMENT_COPY_HPP diff --git a/sprout/sprout/algorithm/fit/transform.hpp b/sprout/sprout/algorithm/fit/transform.hpp new file mode 100644 index 00000000..5655b767 --- /dev/null +++ b/sprout/sprout/algorithm/fit/transform.hpp @@ -0,0 +1,81 @@ +#ifndef SPROUT_ALGORITHM_FIT_TRANSFORM_HPP +#define SPROUT_ALGORITHM_FIT_TRANSFORM_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type transform_impl( + Iterator first, + Iterator last, + Result const& result, + UnaryOperation op, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::transform(first, last, result, op)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last), sprout::size(result)) + ); + } + } // namespace detail + // + // transform + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type transform( + Iterator first, + Iterator last, + Result const& result, + UnaryOperation op + ) + { + return sprout::fit::detail::transform_impl(first, last, result, op, sprout::fixed_begin_offset(result)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type transform_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Result const& result, + BinaryOperation op, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::transform(first1, last1, first2, result, op)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first1, last1), sprout::size(result)) + ); + } + } // namespace detail + // + // transform + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type transform( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Result const& result, + BinaryOperation op + ) + { + return sprout::fit::detail::transform_impl(first1, last1, first2, result, op, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_TRANSFORM_HPP diff --git a/sprout/sprout/algorithm/fit/unique.hpp b/sprout/sprout/algorithm/fit/unique.hpp new file mode 100644 index 00000000..ef10fe1b --- /dev/null +++ b/sprout/sprout/algorithm/fit/unique.hpp @@ -0,0 +1,68 @@ +#ifndef SPROUT_ALGORITHM_FIT_UNIQUE_HPP +#define SPROUT_ALGORITHM_FIT_UNIQUE_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type unique_impl( + Container const& cont, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::unique(cont)), + offset, + offset + sprout::size(cont) - sprout::detail::overlap_count(sprout::begin(cont), sprout::end(cont)) + ); + } + } // namespace detail + // + // unique + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type unique( + Container const& cont + ) + { + return sprout::fit::detail::unique_impl(cont, sprout::fixed_begin_offset(cont)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type unique_impl( + Container const& cont, + BinaryPredicate pred, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::unique(cont, pred)), + offset, + offset + sprout::size(cont) - sprout::detail::overlap_count(sprout::begin(cont), sprout::end(cont), pred) + ); + } + } // namespace detail + // + // unique + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type unique( + Container const& cont, + BinaryPredicate pred + ) + { + return sprout::fit::detail::unique_impl(cont, pred, sprout::fixed_begin_offset(cont)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_UNIQUE_HPP diff --git a/sprout/sprout/algorithm/fit/unique_copy.hpp b/sprout/sprout/algorithm/fit/unique_copy.hpp new file mode 100644 index 00000000..37e3afdc --- /dev/null +++ b/sprout/sprout/algorithm/fit/unique_copy.hpp @@ -0,0 +1,78 @@ +#ifndef SPROUT_ALGORITHM_FIT_UNIQUE_COPY_HPP +#define SPROUT_ALGORITHM_FIT_UNIQUE_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fit { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type unique_copy_impl( + Iterator first, + Iterator last, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::unique_copy(first, last, result)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last) - sprout::detail::overlap_count(first, last), sprout::size(result)) + ); + } + } // namespace detail + // + // unique_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type unique_copy( + Iterator first, + Iterator last, + Result const& result + ) + { + return sprout::fit::detail::unique_copy_impl(first, last, result, sprout::fixed_begin_offset(result)); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type unique_copy_impl( + Iterator first, + Iterator last, + Result const& result, + BinaryPredicate pred, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::unique_copy(first, last, result, pred)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last) - sprout::detail::overlap_count(first, last, pred), sprout::size(result)) + ); + } + } // namespace detail + // + // unique_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type unique_copy( + Iterator first, + Iterator last, + Result const& result, + BinaryPredicate pred + ) + { + return sprout::fit::detail::unique_copy_impl(first, last, result, pred, sprout::fixed_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIT_UNIQUE_COPY_HPP diff --git a/sprout/sprout/algorithm/fixed.hpp b/sprout/sprout/algorithm/fixed.hpp new file mode 100644 index 00000000..4352f602 --- /dev/null +++ b/sprout/sprout/algorithm/fixed.hpp @@ -0,0 +1,50 @@ +#ifndef SPROUT_ALGORITHM_FIXED_HPP +#define SPROUT_ALGORITHM_FIXED_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_HPP diff --git a/sprout/sprout/algorithm/fixed/copy.hpp b/sprout/sprout/algorithm/fixed/copy.hpp new file mode 100644 index 00000000..c89dceef --- /dev/null +++ b/sprout/sprout/algorithm/fixed/copy.hpp @@ -0,0 +1,61 @@ +#ifndef SPROUT_ALGORITHM_FIXED_COPY_HPP +#define SPROUT_ALGORITHM_FIXED_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type copy_impl( + Iterator first, + Iterator last, + Result const& result, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, + typename sprout::fixed_container_traits::size_type input_size + ) + { + return sprout::remake_clone( + result, + sprout::size(result), + (Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size + ? *(first + Indexes - offset) + : *(sprout::fixed_begin(result) + Indexes) + )... + ); + } + } // namespace detail + // + // copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type copy( + Iterator first, + Iterator last, + Result const& result + ) + { + return sprout::fixed::detail::copy_impl( + first, + last, + result, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type(), + sprout::fixed_begin_offset(result), + sprout::size(result), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last) + ); + } + } // namespace fixed + + using sprout::fixed::copy; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_COPY_HPP diff --git a/sprout/sprout/algorithm/fixed/copy_backward.hpp b/sprout/sprout/algorithm/fixed/copy_backward.hpp new file mode 100644 index 00000000..5242e7be --- /dev/null +++ b/sprout/sprout/algorithm/fixed/copy_backward.hpp @@ -0,0 +1,61 @@ +#ifndef SPROUT_ALGORITHM_FIXED_COPY_BACKWARD_HPP +#define SPROUT_ALGORITHM_FIXED_COPY_BACKWARD_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type copy_backward_impl( + Iterator first, + Iterator last, + Result const& result, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, + typename sprout::fixed_container_traits::size_type input_size + ) + { + return sprout::remake_clone( + result, + sprout::size(result), + (Indexes < offset && Indexes + size >= offset && Indexes + input_size >= offset + ? *(last + Indexes - offset) + : *(sprout::fixed_begin(result) + Indexes) + )... + ); + } + } // namespace detail + // + // copy_backward + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type copy_backward( + Iterator first, + Iterator last, + Result const& result + ) + { + return sprout::fixed::detail::copy_backward_impl( + first, + last, + result, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type(), + sprout::fixed_end_offset(result), + sprout::size(result), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last) + ); + } + } // namespace fixed + + using sprout::fixed::copy_backward; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_COPY_BACKWARD_HPP diff --git a/sprout/sprout/algorithm/fixed/copy_if.hpp b/sprout/sprout/algorithm/fixed/copy_if.hpp new file mode 100644 index 00000000..7884f751 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/copy_if.hpp @@ -0,0 +1,132 @@ +#ifndef SPROUT_ALGORITHM_FIXED_COPY_IF_HPP +#define SPROUT_ALGORITHM_FIXED_COPY_IF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type copy_if_impl_3( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type copy_if_impl_3( + Result const& result, + Args const&... args + ) + { + return copy_if_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type copy_if_impl_2( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type copy_if_impl_2( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return first != last && sizeof...(Args) < offset + ? pred(*first) + ? copy_if_impl_2(first + 1, last, result, pred, offset, args..., *first) + : copy_if_impl_2(first + 1, last, result, pred, offset, args...) + : copy_if_impl_3(result, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type copy_if_impl_1( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type copy_if_impl_1( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? copy_if_impl_1(first, last, result, pred, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) + : copy_if_impl_2(first, last, result, pred, offset + sprout::size(result), args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type copy_if_impl( + Iterator first, + Iterator last, + Result const& result, + Predicate pred + ) + { + return copy_if_impl_1(first, last, result, pred, sprout::fixed_begin_offset(result)); + } + } // namespace detail + // + // copy_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type copy_if( + Iterator first, + Iterator last, + Result const& result, + Predicate pred + ) + { + return sprout::fixed::detail::copy_if_impl(first, last, result, pred); + } + } // namespace fixed + + using sprout::fixed::copy_if; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_COPY_IF_HPP diff --git a/sprout/sprout/algorithm/fixed/copy_n.hpp b/sprout/sprout/algorithm/fixed/copy_n.hpp new file mode 100644 index 00000000..43d3b2bc --- /dev/null +++ b/sprout/sprout/algorithm/fixed/copy_n.hpp @@ -0,0 +1,37 @@ +#ifndef SPROUT_ALGORITHM_FIXED_COPY_N_HPP +#define SPROUT_ALGORITHM_FIXED_COPY_N_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // copy_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type copy_n( + Iterator first, + Size n, + Result const& result + ) + { + return sprout::fixed::detail::copy_impl( + first, + first + n, + result, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type(), + sprout::fixed_begin_offset(result), + sprout::size(result), + n + ); + } + } // namespace fixed + + using sprout::fixed::copy_n; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_COPY_N_HPP diff --git a/sprout/sprout/algorithm/fixed/fill.hpp b/sprout/sprout/algorithm/fixed/fill.hpp new file mode 100644 index 00000000..24affc14 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/fill.hpp @@ -0,0 +1,55 @@ +#ifndef SPROUT_ALGORITHM_FIXED_FILL_HPP +#define SPROUT_ALGORITHM_FIXED_FILL_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type fill_impl( + Container const& cont, + sprout::index_tuple, + T const& value, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size + ) + { + return sprout::remake_clone( + cont, + sprout::size(cont), + (Indexes >= offset && Indexes < offset + size + ? value + : *(sprout::fixed_begin(cont) + Indexes) + )... + ); + } + } // namespace detail + // + // fill + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type fill( + Container const& cont, + T const& value + ) + { + return sprout::fixed::detail::fill_impl( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type(), + value, + sprout::fixed_begin_offset(cont), + sprout::size(cont) + ); + } + } // namespace fixed + + using sprout::fixed::fill; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_FILL_HPP diff --git a/sprout/sprout/algorithm/fixed/fill_n.hpp b/sprout/sprout/algorithm/fixed/fill_n.hpp new file mode 100644 index 00000000..3d7c4f8d --- /dev/null +++ b/sprout/sprout/algorithm/fixed/fill_n.hpp @@ -0,0 +1,36 @@ +#ifndef SPROUT_ALGORITHM_FIXED_FILL_N_HPP +#define SPROUT_ALGORITHM_FIXED_FILL_N_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // fill_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type fill_n( + Container const& cont, + Size n, + T const& value + ) + { + return sprout::fixed::detail::fill_impl( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type(), + value, + sprout::fixed_begin_offset(cont), + n + ); + } + } // namespace fixed + + using sprout::fixed::fill_n; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_FILL_N_HPP diff --git a/sprout/sprout/algorithm/fixed/generate.hpp b/sprout/sprout/algorithm/fixed/generate.hpp new file mode 100644 index 00000000..ce1c9bc2 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/generate.hpp @@ -0,0 +1,196 @@ +#ifndef SPROUT_ALGORITHM_FIXED_GENERATE_HPP +#define SPROUT_ALGORITHM_FIXED_GENERATE_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + InitSize == sizeof...(Args) + 1, + typename sprout::fixed_container_traits::value_type + >::type call_gen( + Generator gen, + Head const& head, + Args const&... args + ) + { + return gen(head, args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + InitSize != sizeof...(Args) + 1, + typename sprout::fixed_container_traits::value_type + >::type call_gen( + Generator gen, + Head const& head, + Args const&... args + ) + { + return call_gen(gen, args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type generate_impl_4( + Container const& cont, + Args const&... args + ) + { + return sprout::remake_clone(cont, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type generate_impl_4( + Container const& cont, + Args const&... args + ) + { + return generate_impl_4(cont, args..., *(sprout::fixed_begin(cont) + sizeof...(Args))); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type generate_impl_3( + Container const& cont, + Generator gen, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(cont, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type generate_impl_3( + Container const& cont, + Generator gen, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? generate_impl_3(cont, gen, offset, args..., call_gen(gen, args...)) + : generate_impl_4(cont, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sizeof...(Args) == 0, + typename sprout::fixed::result_of::algorithm::type + >::type generate_impl_2_drop( + Container const& cont, + typename sprout::fixed_container_traits::size_type dropped_size, + Head const& head, + Args const&... args + ) + { + return sprout::remake_clone(cont, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sizeof...(Args) != 0, + typename sprout::fixed::result_of::algorithm::type + >::type generate_impl_2_drop( + Container const& cont, + typename sprout::fixed_container_traits::size_type dropped_size, + Head const& head, + Args const&... args + ) + { + return sizeof...(Args) + 1 != dropped_size + ? generate_impl_2_drop(cont, dropped_size, args...) + : generate_impl_4(cont, head, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type generate_impl_2( + Container const& cont, + Generator gen, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, + std::size_t remain, + Head const& head, + Args const&... args + ) + { + return InitSize - remain != size + ? (remain > 1 + ? generate_impl_2(cont, gen, offset, size, remain - 1, args..., head) + : generate_impl_3(cont, gen, offset + size, args..., head) + ) + : generate_impl_2_drop(cont, offset + size, head, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type generate_impl_1( + Container const& cont, + Generator gen, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, + Args const&... args + ) + { + return generate_impl_2(cont, gen, offset, size, InitSize, args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type generate_impl_1( + Container const& cont, + Generator gen, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, + Args const&... args + ) + { + return sizeof...(Args) - InitSize < offset + ? generate_impl_1(cont, gen, offset, size, args..., *(sprout::fixed_begin(cont) + sizeof...(Args) - InitSize)) + : generate_impl_2(cont, gen, offset, size, InitSize, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type generate_impl( + Container const& cont, + Generator gen, + typename sprout::fixed_container_traits::size_type size, + Inits const&... inits + ) + { + return generate_impl_1(cont, gen, sprout::fixed_begin_offset(cont), size, inits...); + } + } // namespace detail + // + // generate + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type generate( + Container const& cont, + Generator gen, + Inits const&... inits + ) + { + return sprout::fixed::detail::generate_impl(cont, gen, sprout::size(cont), inits...); + } + } // namespace fixed + + using sprout::fixed::generate; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_GENERATE_HPP diff --git a/sprout/sprout/algorithm/fixed/generate_n.hpp b/sprout/sprout/algorithm/fixed/generate_n.hpp new file mode 100644 index 00000000..e97992f9 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/generate_n.hpp @@ -0,0 +1,29 @@ +#ifndef SPROUT_ALGORITHM_FIXED_GENERATE_N_HPP +#define SPROUT_ALGORITHM_FIXED_GENERATE_N_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // generate_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type generate_n( + Container const& cont, + Size n, + Generator gen, + Inits const&... inits + ) + { + return sprout::fixed::detail::generate_impl(cont, gen, n, inits...); + } + } // namespace fixed + + using sprout::fixed::generate_n; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_GENERATE_N_HPP diff --git a/sprout/sprout/algorithm/fixed/inplace_merge.hpp b/sprout/sprout/algorithm/fixed/inplace_merge.hpp new file mode 100644 index 00000000..526971d8 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/inplace_merge.hpp @@ -0,0 +1,53 @@ +#ifndef SPROUT_ALGORITHM_FIXED_INPLACE_MERGE_HPP +#define SPROUT_ALGORITHM_FIXED_INPLACE_MERGE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // inplace_merge + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type inplace_merge( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + Compare comp + ) + { + return sprout::fixed::merge( + sprout::begin(cont), + middle, + middle, + sprout::end(cont), + cont, + comp + ); + } + // + // inplace_merge + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type inplace_merge( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle + ) + { + return sprout::fixed::merge( + sprout::begin(cont), + middle, + middle, + sprout::end(cont), + cont + ); + } + } // namespace fixed + + using sprout::fixed::inplace_merge; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_INPLACE_MERGE_HPP diff --git a/sprout/sprout/algorithm/fixed/make_heap.hpp b/sprout/sprout/algorithm/fixed/make_heap.hpp new file mode 100644 index 00000000..910869e9 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/make_heap.hpp @@ -0,0 +1,125 @@ +#ifndef SPROUT_ALGORITHM_FIXED_MAKE_HEAP_HPP +#define SPROUT_ALGORITHM_FIXED_MAKE_HEAP_HPP + +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type make_heap_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::difference_type size, + typename sprout::fixed_container_traits::difference_type n = 0, + typename sprout::fixed_container_traits::difference_type l = 1, + typename sprout::fixed_container_traits::difference_type r = 2 + ); + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type make_heap_impl_1( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::difference_type size, + typename sprout::fixed_container_traits::difference_type n, + typename sprout::fixed_container_traits::difference_type l, + typename sprout::fixed_container_traits::difference_type r + ) + { + return comp(*(sprout::fixed_begin(cont) + offset + l), *(sprout::fixed_begin(cont) + offset + r)) + ? comp(*(sprout::fixed_begin(cont) + offset + n), *(sprout::fixed_begin(cont) + offset + r)) + ? sprout::fixed::detail::make_heap_impl( + sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + n, sprout::fixed_begin(cont) + offset + r), + comp, + offset, + size, + r, + r * 2 + 1, + r * 2 + 2 + ) + : sprout::clone(cont) + : comp(*(sprout::fixed_begin(cont) + offset + n), *(sprout::fixed_begin(cont) + offset + l)) + ? sprout::fixed::detail::make_heap_impl( + sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + n, sprout::fixed_begin(cont) + offset + l), + comp, + offset, + size, + l, + l * 2 + 1, + l * 2 + 2 + ) + : sprout::clone(cont) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type make_heap_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::difference_type size, + typename sprout::fixed_container_traits::difference_type n, + typename sprout::fixed_container_traits::difference_type l, + typename sprout::fixed_container_traits::difference_type r + ) + { + return r > size + ? sprout::clone(cont) + : r == size + ? comp(*(sprout::fixed_begin(cont) + offset + n), *(sprout::fixed_begin(cont) + offset + l)) + ? sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + n, sprout::fixed_begin(cont) + offset + l) + : sprout::clone(cont) + : sprout::fixed::detail::make_heap_impl_1( + sprout::fixed::detail::make_heap_impl(sprout::fixed::detail::make_heap_impl(cont, comp, offset, size, l, l * 2 + 1, l * 2 + 2), comp, offset, size, r, r * 2 + 1, r * 2 + 2), + comp, + offset, + size, + n, + l, + r + ) + ; + } + } // namespace detail + // + // make_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type make_heap( + Container const& cont, + Compare comp + ) + { + return sprout::fixed::detail::make_heap_impl( + cont, + comp, + sprout::fixed_begin_offset(cont), + sprout::size(cont) + ); + } + // + // make_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type make_heap( + Container const& cont + ) + { + return sprout::fixed::detail::make_heap_impl( + cont, + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>(), + sprout::fixed_begin_offset(cont), + sprout::size(cont) + ); + } + } // namespace fixed + + using sprout::fixed::make_heap; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_MAKE_HEAP_HPP diff --git a/sprout/sprout/algorithm/fixed/make_partial_heap.hpp b/sprout/sprout/algorithm/fixed/make_partial_heap.hpp new file mode 100644 index 00000000..d0e6aec9 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/make_partial_heap.hpp @@ -0,0 +1,105 @@ +#ifndef SPROUT_ALGORITHM_FIXED_MAKE_PARTIAL_HEAP_HPP +#define SPROUT_ALGORITHM_FIXED_MAKE_PARTIAL_HEAP_HPP + +#include +#include +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type make_partial_heap_impl_1( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::difference_type size, + typename sprout::fixed_container_traits::difference_type middle_size, + typename sprout::fixed_container_traits::difference_type n + ) + { + return n < size + ? comp(*(sprout::fixed_begin(cont) + offset + n), *(sprout::fixed_begin(cont) + offset)) + ? sprout::fixed::detail::make_partial_heap_impl_1( + sprout::fixed::detail::pop_heap_impl( + sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + n, sprout::fixed_begin(cont) + offset), + comp, + offset, + middle_size + ), + comp, + offset, + size, + middle_size, + n + 1 + ) + : sprout::fixed::detail::make_partial_heap_impl_1(cont, comp, offset, size, middle_size, n + 1) + : sprout::clone(cont) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type make_partial_heap_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::difference_type size, + typename sprout::fixed_container_traits::difference_type middle_size + ) + { + return sprout::fixed::detail::make_partial_heap_impl_1( + sprout::fixed::detail::make_heap_impl(cont, comp, offset, middle_size), + comp, + offset, + size, + middle_size, + middle_size + ); + } + } // namespace detail + // + // make_partial_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type make_partial_heap( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + Compare comp + ) + { + return sprout::fixed::detail::make_partial_heap_impl( + cont, + comp, + sprout::fixed_begin_offset(cont), + sprout::size(cont), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), middle) + ); + } + // + // make_partial_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type make_partial_heap( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle + ) + { + return sprout::fixed::detail::make_partial_heap_impl( + cont, + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>(), + sprout::fixed_begin_offset(cont), + sprout::size(cont), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), middle) + ); + } + } // namespace fixed + + using sprout::fixed::make_partial_heap; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_MAKE_PARTIAL_HEAP_HPP diff --git a/sprout/sprout/algorithm/fixed/merge.hpp b/sprout/sprout/algorithm/fixed/merge.hpp new file mode 100644 index 00000000..d3720c8e --- /dev/null +++ b/sprout/sprout/algorithm/fixed/merge.hpp @@ -0,0 +1,179 @@ +#ifndef SPROUT_ALGORITHM_FIXED_MERGE_HPP +#define SPROUT_ALGORITHM_FIXED_MERGE_HPP + +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type merge_impl_3( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type merge_impl_3( + Result const& result, + Args const&... args + ) + { + return merge_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type merge_impl_2( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type merge_impl_2( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? first1 != last1 + ? first2 != last2 + ? comp(*first2, *first1) + ? merge_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args..., *first2) + : merge_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) + : merge_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) + : first2 != last2 + ? merge_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args..., *first2) + : merge_impl_3(result, args...) + : merge_impl_3(result, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type merge_impl_1( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type merge_impl_1( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? merge_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) + : merge_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type merge_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return merge_impl_1(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result)); + } + } // namespace detail + // + // merge + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type merge( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return sprout::fixed::detail::merge_impl( + first1, + last1, + first2, + last2, + result, + comp + ); + } + // + // merge + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type merge( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result + ) + { + return sprout::fixed::detail::merge_impl( + first1, + last1, + first2, + last2, + result, + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>() + ); + } + } // namespace fixed + + using sprout::fixed::merge; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_MERGE_HPP diff --git a/sprout/sprout/algorithm/fixed/nth_element.hpp b/sprout/sprout/algorithm/fixed/nth_element.hpp new file mode 100644 index 00000000..ba2c2a01 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/nth_element.hpp @@ -0,0 +1,85 @@ +#ifndef SPROUT_ALGORITHM_FIXED_NTH_ELEMENT_HPP +#define SPROUT_ALGORITHM_FIXED_NTH_ELEMENT_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type nth_element_impl_1( + Container const& cont, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::difference_type nth_size + ) + { + return sprout::fixed::swap_element( + cont, + sprout::fixed_begin(cont) + offset, + sprout::fixed_begin(cont) + offset + nth_size + ); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type nth_element_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::difference_type size, + typename sprout::fixed_container_traits::difference_type nth_size + ) + { + return sprout::fixed::detail::nth_element_impl_1( + sprout::fixed::detail::make_partial_heap_impl(cont, comp, offset, size, nth_size + 1), + offset, + nth_size + ); + } + } // namespace detail + // + // nth_element + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type nth_element( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator nth, + Compare comp + ) + { + return sprout::fixed::detail::nth_element_impl( + cont, + comp, + sprout::fixed_begin_offset(cont), + sprout::size(cont), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), nth) + ); + } + // + // nth_element + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type nth_element( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator nth + ) + { + return sprout::fixed::detail::nth_element_impl( + cont, + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>(), + sprout::fixed_begin_offset(cont), + sprout::size(cont), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), nth) + ); + } + } // namespace fixed + + using sprout::fixed::nth_element; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_NTH_ELEMENT_HPP diff --git a/sprout/sprout/algorithm/fixed/partial_sort.hpp b/sprout/sprout/algorithm/fixed/partial_sort.hpp new file mode 100644 index 00000000..ed9c948c --- /dev/null +++ b/sprout/sprout/algorithm/fixed/partial_sort.hpp @@ -0,0 +1,73 @@ +#ifndef SPROUT_ALGORITHM_FIXED_PARTIAL_SORT_HPP +#define SPROUT_ALGORITHM_FIXED_PARTIAL_SORT_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type partial_sort_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::difference_type size, + typename sprout::fixed_container_traits::difference_type middle_size + ) + { + return sprout::fixed::detail::sort_heap_impl( + sprout::fixed::detail::make_partial_heap_impl(cont, comp, offset, size, middle_size), + comp, + offset, + middle_size + ); + } + } // namespace detail + // + // partial_sort + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type partial_sort( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle, + Compare comp + ) + { + return sprout::fixed::detail::partial_sort_impl( + cont, + comp, + sprout::fixed_begin_offset(cont), + sprout::size(cont), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), middle) + ); + } + // + // partial_sort + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type partial_sort( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle + ) + { + return sprout::fixed::detail::partial_sort_impl( + cont, + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>(), + sprout::fixed_begin_offset(cont), + sprout::size(cont), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), middle) + ); + } + } // namespace fixed + + using sprout::fixed::partial_sort; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_PARTIAL_SORT_HPP diff --git a/sprout/sprout/algorithm/fixed/partition.hpp b/sprout/sprout/algorithm/fixed/partition.hpp new file mode 100644 index 00000000..2b973446 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/partition.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_ALGORITHM_FIXED_PARTITION_HPP +#define SPROUT_ALGORITHM_FIXED_PARTITION_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // partition + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type partition( + Container const& cont, + Predicate pred + ) + { + return sprout::fixed::partition_copy(sprout::begin(cont), sprout::end(cont), cont, pred); + } + } // namespace fixed + + using sprout::fixed::partition; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_PARTITION_HPP diff --git a/sprout/sprout/algorithm/fixed/partition_copy.hpp b/sprout/sprout/algorithm/fixed/partition_copy.hpp new file mode 100644 index 00000000..52bf59b6 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/partition_copy.hpp @@ -0,0 +1,132 @@ +#ifndef SPROUT_ALGORITHM_FIXED_PARTITION_COPY_HPP +#define SPROUT_ALGORITHM_FIXED_PARTITION_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type partition_copy_impl_3( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type partition_copy_impl_3( + Result const& result, + Args const&... args + ) + { + return partition_copy_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type partition_copy_impl_2( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type partition_copy_impl_2( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return first != last && sizeof...(Args) < offset + ? pred(*first) + ? partition_copy_impl_2(first + 1, last, result, pred, offset, *first, args...) + : partition_copy_impl_2(first + 1, last, result, pred, offset, args..., *first) + : partition_copy_impl_3(result, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type partition_copy_impl_1( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type partition_copy_impl_1( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? partition_copy_impl_1(first, last, result, pred, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) + : partition_copy_impl_2(first, last, result, pred, offset + sprout::size(result), args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type partition_copy_impl( + Iterator first, + Iterator last, + Result const& result, + Predicate pred + ) + { + return partition_copy_impl_1(first, last, result, pred, sprout::fixed_begin_offset(result)); + } + } // namespace detail + // + // partition_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type partition_copy( + Iterator first, + Iterator last, + Result const& result, + Predicate pred + ) + { + return sprout::fixed::detail::partition_copy_impl(first, last, result, pred); + } + } // namespace fixed + + using sprout::fixed::partition_copy; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_PARTITION_COPY_HPP diff --git a/sprout/sprout/algorithm/fixed/pop_heap.hpp b/sprout/sprout/algorithm/fixed/pop_heap.hpp new file mode 100644 index 00000000..4ab2a6bb --- /dev/null +++ b/sprout/sprout/algorithm/fixed/pop_heap.hpp @@ -0,0 +1,89 @@ +#ifndef SPROUT_ALGORITHM_FIXED_POP_HEAP_HPP +#define SPROUT_ALGORITHM_FIXED_POP_HEAP_HPP + +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type pop_heap_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::difference_type size, + typename sprout::fixed_container_traits::difference_type n = 0, + typename sprout::fixed_container_traits::difference_type l = 1, + typename sprout::fixed_container_traits::difference_type r = 2 + ) + { + return r < size && comp(*(sprout::fixed_begin(cont) + offset + l), *(sprout::fixed_begin(cont) + offset + r)) + ? comp(*(sprout::fixed_begin(cont) + offset + n), *(sprout::fixed_begin(cont) + offset + r)) + ? sprout::fixed::detail::pop_heap_impl( + sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + n, sprout::fixed_begin(cont) + offset + r), + comp, + offset, + size, + r, + r * 2 + 1, + r * 2 + 2 + ) + : sprout::clone(cont) + : l < size + ? comp(*(sprout::fixed_begin(cont) + offset + n), *(sprout::fixed_begin(cont) + offset + l)) + ? sprout::fixed::detail::pop_heap_impl( + sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + n, sprout::fixed_begin(cont) + offset + l), + comp, + offset, + size, + l, + l * 2 + 1, + l * 2 + 2 + ) + : sprout::clone(cont) + : sprout::clone(cont) + ; + } + } // namespace detail + // + // pop_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type pop_heap( + Container const& cont, + Compare comp + ) + { + return sprout::fixed::detail::pop_heap_impl( + sprout::fixed::swap_element(cont, sprout::begin(cont), sprout::end(cont) - 1), + comp, + sprout::fixed_begin_offset(cont), + sprout::size(cont) - 1 + ); + } + // + // pop_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type pop_heap( + Container const& cont + ) + { + return sprout::fixed::detail::pop_heap_impl( + sprout::fixed::swap_element(cont, sprout::begin(cont), sprout::end(cont) - 1), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>(), + sprout::fixed_begin_offset(cont), + sprout::size(cont) - 1 + ); + } + } // namespace fixed + + using sprout::fixed::pop_heap; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_POP_HEAP_HPP diff --git a/sprout/sprout/algorithm/fixed/push_heap.hpp b/sprout/sprout/algorithm/fixed/push_heap.hpp new file mode 100644 index 00000000..15ab1bfb --- /dev/null +++ b/sprout/sprout/algorithm/fixed/push_heap.hpp @@ -0,0 +1,69 @@ +#ifndef SPROUT_ALGORITHM_FIXED_PUSH_HEAP_HPP +#define SPROUT_ALGORITHM_FIXED_PUSH_HEAP_HPP + +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type push_heap_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::difference_type n + ) + { + return n != 0 && comp(*(sprout::fixed_begin(cont) + offset + (n - 1) / 2), *(sprout::fixed_begin(cont) + offset + n)) + ? sprout::fixed::detail::push_heap_impl( + sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + (n - 1) / 2, sprout::fixed_begin(cont) + offset + n), + comp, + offset, + (n - 1) / 2 + ) + : sprout::clone(cont) + ; + } + } // namespace detail + // + // push_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type push_heap( + Container const& cont, + Compare comp + ) + { + return sprout::fixed::detail::push_heap_impl( + cont, + comp, + sprout::fixed_begin_offset(cont), + sprout::size(cont) - 1 + ); + } + // + // push_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type push_heap( + Container const& cont + ) + { + return sprout::fixed::detail::push_heap_impl( + cont, + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>(), + sprout::fixed_begin_offset(cont), + sprout::size(cont) - 1 + ); + } + } // namespace fixed + + using sprout::fixed::push_heap; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_PUSH_HEAP_HPP diff --git a/sprout/sprout/algorithm/fixed/remove.hpp b/sprout/sprout/algorithm/fixed/remove.hpp new file mode 100644 index 00000000..1189c224 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/remove.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_ALGORITHM_FIXED_REMOVE_HPP +#define SPROUT_ALGORITHM_FIXED_REMOVE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // remove + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type remove( + Container const& cont, + T const& value + ) + { + return sprout::fixed::remove_copy(sprout::begin(cont), sprout::end(cont), cont, value); + } + } // namespace fixed + + using sprout::fixed::remove; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_REMOVE_HPP diff --git a/sprout/sprout/algorithm/fixed/remove_copy.hpp b/sprout/sprout/algorithm/fixed/remove_copy.hpp new file mode 100644 index 00000000..d7f6f410 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/remove_copy.hpp @@ -0,0 +1,132 @@ +#ifndef SPROUT_ALGORITHM_FIXED_REMOVE_COPY_HPP +#define SPROUT_ALGORITHM_FIXED_REMOVE_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type remove_copy_impl_3( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type remove_copy_impl_3( + Result const& result, + Args const&... args + ) + { + return remove_copy_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type remove_copy_impl_2( + Iterator first, + Iterator last, + Result const& result, + T const& value, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type remove_copy_impl_2( + Iterator first, + Iterator last, + Result const& result, + T const& value, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return first != last && sizeof...(Args) < offset + ? *first == value + ? remove_copy_impl_2(first + 1, last, result, value, offset, args...) + : remove_copy_impl_2(first + 1, last, result, value, offset, args..., *first) + : remove_copy_impl_3(result, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type remove_copy_impl_1( + Iterator first, + Iterator last, + Result const& result, + T const& value, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type remove_copy_impl_1( + Iterator first, + Iterator last, + Result const& result, + T const& value, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? remove_copy_impl_1(first, last, result, value, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) + : remove_copy_impl_2(first, last, result, value, offset + sprout::size(result), args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type remove_copy_impl( + Iterator first, + Iterator last, + Result const& result, + T const& value + ) + { + return remove_copy_impl_1(first, last, result, value, sprout::fixed_begin_offset(result)); + } + } // namespace detail + // + // remove_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type remove_copy( + Iterator first, + Iterator last, + Result const& result, + T const& value + ) + { + return sprout::fixed::detail::remove_copy_impl(first, last, result, value); + } + } // namespace fixed + + using sprout::fixed::remove_copy; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_REMOVE_COPY_HPP diff --git a/sprout/sprout/algorithm/fixed/remove_copy_if.hpp b/sprout/sprout/algorithm/fixed/remove_copy_if.hpp new file mode 100644 index 00000000..2856ca50 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/remove_copy_if.hpp @@ -0,0 +1,132 @@ +#ifndef SPROUT_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP +#define SPROUT_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type remove_copy_if_impl_3( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type remove_copy_if_impl_3( + Result const& result, + Args const&... args + ) + { + return remove_copy_if_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type remove_copy_if_impl_2( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type remove_copy_if_impl_2( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return first != last && sizeof...(Args) < offset + ? pred(*first) + ? remove_copy_if_impl_2(first + 1, last, result, pred, offset, args...) + : remove_copy_if_impl_2(first + 1, last, result, pred, offset, args..., *first) + : remove_copy_if_impl_3(result, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type remove_copy_if_impl_1( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type remove_copy_if_impl_1( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? remove_copy_if_impl_1(first, last, result, pred, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) + : remove_copy_if_impl_2(first, last, result, pred, offset + sprout::size(result), args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type remove_copy_if_impl( + Iterator first, + Iterator last, + Result const& result, + Predicate pred + ) + { + return remove_copy_if_impl_1(first, last, result, pred, sprout::fixed_begin_offset(result)); + } + } // namespace detail + // + // remove_copy_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type remove_copy_if( + Iterator first, + Iterator last, + Result const& result, + Predicate pred + ) + { + return sprout::fixed::detail::remove_copy_if_impl(first, last, result, pred); + } + } // namespace fixed + + using sprout::fixed::remove_copy_if; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP diff --git a/sprout/sprout/algorithm/fixed/remove_if.hpp b/sprout/sprout/algorithm/fixed/remove_if.hpp new file mode 100644 index 00000000..0348397f --- /dev/null +++ b/sprout/sprout/algorithm/fixed/remove_if.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_ALGORITHM_FIXED_REMOVE_IF_HPP +#define SPROUT_ALGORITHM_FIXED_REMOVE_IF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // remove_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type remove_if( + Container const& cont, + Predicate pred + ) + { + return sprout::fixed::remove_copy_if(sprout::begin(cont), sprout::end(cont), cont, pred); + } + } // namespace fixed + + using sprout::fixed::remove_if; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_REMOVE_IF_HPP diff --git a/sprout/sprout/algorithm/fixed/replace.hpp b/sprout/sprout/algorithm/fixed/replace.hpp new file mode 100644 index 00000000..e2ddf1df --- /dev/null +++ b/sprout/sprout/algorithm/fixed/replace.hpp @@ -0,0 +1,29 @@ +#ifndef SPROUT_ALGORITHM_FIXED_REPLACE_HPP +#define SPROUT_ALGORITHM_FIXED_REPLACE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // replace + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type replace( + Container const& cont, + T const& old_value, + T const& new_value + ) + { + return sprout::fixed::replace_copy(sprout::begin(cont), sprout::end(cont), cont, old_value, new_value); + } + } // namespace fixed + + using sprout::fixed::replace; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_REPLACE_HPP diff --git a/sprout/sprout/algorithm/fixed/replace_copy.hpp b/sprout/sprout/algorithm/fixed/replace_copy.hpp new file mode 100644 index 00000000..c28f6e7c --- /dev/null +++ b/sprout/sprout/algorithm/fixed/replace_copy.hpp @@ -0,0 +1,67 @@ +#ifndef SPROUT_ALGORITHM_FIXED_REPLACE_COPY_HPP +#define SPROUT_ALGORITHM_FIXED_REPLACE_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type replace_copy_impl( + Iterator first, + Iterator last, + Result const& result, + sprout::index_tuple, + T const& old_value, + T const& new_value, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, + typename sprout::fixed_container_traits::size_type input_size + ) + { + return sprout::remake_clone( + result, + sprout::size(result), + (Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size + ? *(first + Indexes - offset) == old_value ? new_value : *(first + Indexes - offset) + : *(sprout::fixed_begin(result) + Indexes) + )... + ); + } + } // namespace detail + // + // replace_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type replace_copy( + Iterator first, + Iterator last, + Result const& result, + T const& old_value, + T const& new_value + ) + { + return sprout::fixed::detail::replace_copy_impl( + first, + last, + result, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type(), + old_value, + new_value, + sprout::fixed_begin_offset(result), + sprout::size(result), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last) + ); + } + } // namespace fixed + + using sprout::fixed::replace_copy; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_REPLACE_COPY_HPP diff --git a/sprout/sprout/algorithm/fixed/replace_copy_if.hpp b/sprout/sprout/algorithm/fixed/replace_copy_if.hpp new file mode 100644 index 00000000..4506ef88 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/replace_copy_if.hpp @@ -0,0 +1,67 @@ +#ifndef SPROUT_ALGORITHM_FIXED_REPLACE_COPY_IF_HPP +#define SPROUT_ALGORITHM_FIXED_REPLACE_COPY_IF_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type replace_copy_if_impl( + Iterator first, + Iterator last, + Result const& result, + sprout::index_tuple, + Predicate pred, + T const& new_value, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, + typename sprout::fixed_container_traits::size_type input_size + ) + { + return sprout::remake_clone( + result, + sprout::size(result), + (Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size + ? pred(*(first + Indexes - offset)) ? new_value : *(first + Indexes - offset) + : *(sprout::fixed_begin(result) + Indexes) + )... + ); + } + } // namespace detail + // + // replace_copy_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type replace_copy_if( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + T const& new_value + ) + { + return sprout::fixed::detail::replace_copy_if_impl( + first, + last, + result, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type(), + pred, + new_value, + sprout::fixed_begin_offset(result), + sprout::size(result), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last) + ); + } + } // namespace fixed + + using sprout::fixed::replace_copy_if; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_REPLACE_COPY_IF_HPP diff --git a/sprout/sprout/algorithm/fixed/replace_if.hpp b/sprout/sprout/algorithm/fixed/replace_if.hpp new file mode 100644 index 00000000..82aee6cb --- /dev/null +++ b/sprout/sprout/algorithm/fixed/replace_if.hpp @@ -0,0 +1,29 @@ +#ifndef SPROUT_ALGORITHM_FIXED_REPLACE_IF_HPP +#define SPROUT_ALGORITHM_FIXED_REPLACE_IF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // replace_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type replace_if( + Container const& cont, + Predicate pred, + T const& new_value + ) + { + return sprout::fixed::replace_copy_if(sprout::begin(cont), sprout::end(cont), cont, pred, new_value); + } + } // namespace fixed + + using sprout::fixed::replace_if; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_REPLACE_IF_HPP diff --git a/sprout/sprout/algorithm/fixed/result_of.hpp b/sprout/sprout/algorithm/fixed/result_of.hpp new file mode 100644 index 00000000..34900b19 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/result_of.hpp @@ -0,0 +1,26 @@ +#ifndef SPROUT_ALGORITHM_FIXED_RESULT_OF_HPP +#define SPROUT_ALGORITHM_FIXED_RESULT_OF_HPP + +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // algorithm + // + template + struct algorithm { + public: + typedef typename sprout::fixed_container_traits::clone_type type; + }; + } // namespace result_of + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::algorithm; + } // namespace result_of +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_RESULT_OF_HPP diff --git a/sprout/sprout/algorithm/fixed/reverse.hpp b/sprout/sprout/algorithm/fixed/reverse.hpp new file mode 100644 index 00000000..99c93128 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/reverse.hpp @@ -0,0 +1,27 @@ +#ifndef SPROUT_ALGORITHM_FIXED_REVERSE_HPP +#define SPROUT_ALGORITHM_FIXED_REVERSE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // reverse + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type reverse( + Container const& cont + ) + { + return sprout::fixed::reverse_copy(sprout::begin(cont), sprout::end(cont), cont); + } + } // namespace fixed + + using sprout::fixed::reverse; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_REVERSE_HPP diff --git a/sprout/sprout/algorithm/fixed/reverse_copy.hpp b/sprout/sprout/algorithm/fixed/reverse_copy.hpp new file mode 100644 index 00000000..44cc5db5 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/reverse_copy.hpp @@ -0,0 +1,62 @@ +#ifndef SPROUT_ALGORITHM_FIXED_REVERSE_COPY_HPP +#define SPROUT_ALGORITHM_FIXED_REVERSE_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type reverse_copy_impl( + Iterator first, + Iterator last, + Result const& result, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, + typename sprout::fixed_container_traits::size_type input_size + ) + { + return sprout::remake_clone( + result, + sprout::size(result), + (Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size + ? *(last - 1 - Indexes + offset) + : *(sprout::fixed_begin(result) + Indexes) + )... + ); + } + } // namespace detail + // + // reverse_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type reverse_copy( + Iterator first, + Iterator last, + Result const& result + ) + { + return sprout::fixed::detail::reverse_copy_impl( + first, + last, + result, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type(), + sprout::fixed_begin_offset(result), + sprout::size(result), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last) + ); + } + } // namespace fixed + + using sprout::fixed::reverse_copy; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_REVERSE_COPY_HPP diff --git a/sprout/sprout/algorithm/fixed/rotate.hpp b/sprout/sprout/algorithm/fixed/rotate.hpp new file mode 100644 index 00000000..fa39394d --- /dev/null +++ b/sprout/sprout/algorithm/fixed/rotate.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_ALGORITHM_FIXED_ROTATE_HPP +#define SPROUT_ALGORITHM_FIXED_ROTATE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // rotate + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type rotate( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator middle + ) + { + return sprout::fixed::rotate_copy(sprout::begin(cont), middle, sprout::end(cont), cont); + } + } // namespace fixed + + using sprout::fixed::rotate; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_ROTATE_HPP diff --git a/sprout/sprout/algorithm/fixed/rotate_copy.hpp b/sprout/sprout/algorithm/fixed/rotate_copy.hpp new file mode 100644 index 00000000..ff827d63 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/rotate_copy.hpp @@ -0,0 +1,67 @@ +#ifndef SPROUT_ALGORITHM_FIXED_ROTATE_COPY_HPP +#define SPROUT_ALGORITHM_FIXED_ROTATE_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type rotate_copy_impl( + Iterator first, + Iterator middle, + Iterator last, + Result const& result, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, + typename sprout::fixed_container_traits::size_type input_size + ) + { + return sprout::remake_clone( + result, + sprout::size(result), + (Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size + ? (Indexes < offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(middle, last) + ? *(middle + Indexes - offset) + : *((first + Indexes - offset) - NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, middle)) + ) + : *(sprout::fixed_begin(result) + Indexes) + )... + ); + } + } // namespace detail + // + // rotate_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type rotate_copy( + Iterator first, + Iterator middle, + Iterator last, + Result const& result + ) + { + return sprout::fixed::detail::rotate_copy_impl( + first, + middle, + last, + result, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type(), + sprout::fixed_begin_offset(result), + sprout::size(result), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last) + ); + } + } // namespace fixed + + using sprout::fixed::rotate_copy; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_ROTATE_COPY_HPP diff --git a/sprout/sprout/algorithm/fixed/set_difference.hpp b/sprout/sprout/algorithm/fixed/set_difference.hpp new file mode 100644 index 00000000..680c3130 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/set_difference.hpp @@ -0,0 +1,181 @@ +#ifndef SPROUT_ALGORITHM_FIXED_SET_DIFFERENCE_HPP +#define SPROUT_ALGORITHM_FIXED_SET_DIFFERENCE_HPP + +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_difference_impl_3( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_difference_impl_3( + Result const& result, + Args const&... args + ) + { + return set_difference_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_difference_impl_2( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_difference_impl_2( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? first1 != last1 + ? first2 != last2 + ? comp(*first1, *first2) + ? set_difference_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) + : comp(*first2, *first1) + ? set_difference_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args...) + : set_difference_impl_2(first1 + 1, last1, first2 + 1, last2, result, comp, offset, args...) + : set_difference_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) + : first2 != last2 + ? set_difference_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args...) + : set_difference_impl_3(result, args...) + : set_difference_impl_3(result, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_difference_impl_1( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_difference_impl_1( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? set_difference_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) + : set_difference_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_difference_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return set_difference_impl_1(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result)); + } + } // namespace detail + // + // set_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_difference( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return sprout::fixed::detail::set_difference_impl( + first1, + last1, + first2, + last2, + result, + comp + ); + } + // + // set_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_difference( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result + ) + { + return sprout::fixed::detail::set_difference_impl( + first1, + last1, + first2, + last2, + result, + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>() + ); + } + } // namespace fixed + + using sprout::fixed::set_difference; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_SET_DIFFERENCE_HPP diff --git a/sprout/sprout/algorithm/fixed/set_intersection.hpp b/sprout/sprout/algorithm/fixed/set_intersection.hpp new file mode 100644 index 00000000..d7a4905b --- /dev/null +++ b/sprout/sprout/algorithm/fixed/set_intersection.hpp @@ -0,0 +1,181 @@ +#ifndef SPROUT_ALGORITHM_FIXED_SET_INTERSECTION_HPP +#define SPROUT_ALGORITHM_FIXED_SET_INTERSECTION_HPP + +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_intersection_impl_3( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_intersection_impl_3( + Result const& result, + Args const&... args + ) + { + return set_intersection_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_intersection_impl_2( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_intersection_impl_2( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? first1 != last1 + ? first2 != last2 + ? comp(*first1, *first2) + ? set_intersection_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args...) + : comp(*first2, *first1) + ? set_intersection_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args...) + : set_intersection_impl_2(first1 + 1, last1, first2 + 1, last2, result, comp, offset, args..., *first1) + : set_intersection_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args...) + : first2 != last2 + ? set_intersection_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args...) + : set_intersection_impl_3(result, args...) + : set_intersection_impl_3(result, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_intersection_impl_1( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_intersection_impl_1( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? set_intersection_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) + : set_intersection_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_intersection_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return set_intersection_impl_1(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result)); + } + } // namespace detail + // + // set_intersection + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_intersection( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return sprout::fixed::detail::set_intersection_impl( + first1, + last1, + first2, + last2, + result, + comp + ); + } + // + // set_intersection + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_intersection( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result + ) + { + return sprout::fixed::detail::set_intersection_impl( + first1, + last1, + first2, + last2, + result, + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>() + ); + } + } // namespace fixed + + using sprout::fixed::set_intersection; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_SET_INTERSECTION_HPP diff --git a/sprout/sprout/algorithm/fixed/set_symmetric_difference.hpp b/sprout/sprout/algorithm/fixed/set_symmetric_difference.hpp new file mode 100644 index 00000000..226684df --- /dev/null +++ b/sprout/sprout/algorithm/fixed/set_symmetric_difference.hpp @@ -0,0 +1,181 @@ +#ifndef SPROUT_ALGORITHM_FIXED_SET_SYMMETRIC_DIFFERENCE_HPP +#define SPROUT_ALGORITHM_FIXED_SET_SYMMETRIC_DIFFERENCE_HPP + +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_symmetric_difference_impl_3( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_symmetric_difference_impl_3( + Result const& result, + Args const&... args + ) + { + return set_symmetric_difference_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_symmetric_difference_impl_2( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_symmetric_difference_impl_2( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? first1 != last1 + ? first2 != last2 + ? comp(*first1, *first2) + ? set_symmetric_difference_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) + : comp(*first2, *first1) + ? set_symmetric_difference_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args..., *first2) + : set_symmetric_difference_impl_2(first1 + 1, last1, first2 + 1, last2, result, comp, offset, args...) + : set_symmetric_difference_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) + : first2 != last2 + ? set_symmetric_difference_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args..., *first2) + : set_symmetric_difference_impl_3(result, args...) + : set_symmetric_difference_impl_3(result, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_symmetric_difference_impl_1( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_symmetric_difference_impl_1( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? set_symmetric_difference_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) + : set_symmetric_difference_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_symmetric_difference_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return set_symmetric_difference_impl_1(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result)); + } + } // namespace detail + // + // set_symmetric_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_symmetric_difference( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return sprout::fixed::detail::set_symmetric_difference_impl( + first1, + last1, + first2, + last2, + result, + comp + ); + } + // + // set_symmetric_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_symmetric_difference( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result + ) + { + return sprout::fixed::detail::set_symmetric_difference_impl( + first1, + last1, + first2, + last2, + result, + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>() + ); + } + } // namespace fixed + + using sprout::fixed::set_symmetric_difference; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_SET_SYMMETRIC_DIFFERENCE_HPP diff --git a/sprout/sprout/algorithm/fixed/set_union.hpp b/sprout/sprout/algorithm/fixed/set_union.hpp new file mode 100644 index 00000000..63cf17c6 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/set_union.hpp @@ -0,0 +1,181 @@ +#ifndef SPROUT_ALGORITHM_FIXED_SET_UNION_HPP +#define SPROUT_ALGORITHM_FIXED_SET_UNION_HPP + +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_union_impl_3( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_union_impl_3( + Result const& result, + Args const&... args + ) + { + return set_union_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_union_impl_2( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_union_impl_2( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? first1 != last1 + ? first2 != last2 + ? comp(*first1, *first2) + ? set_union_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) + : comp(*first2, *first1) + ? set_union_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args..., *first2) + : set_union_impl_2(first1 + 1, last1, first2 + 1, last2, result, comp, offset, args..., *first1) + : set_union_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) + : first2 != last2 + ? set_union_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args..., *first2) + : set_union_impl_3(result, args...) + : set_union_impl_3(result, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_union_impl_1( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type set_union_impl_1( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? set_union_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) + : set_union_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_union_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return set_union_impl_1(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result)); + } + } // namespace detail + // + // set_union + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_union( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result, + Compare comp + ) + { + return sprout::fixed::detail::set_union_impl( + first1, + last1, + first2, + last2, + result, + comp + ); + } + // + // set_union + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_union( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Result const& result + ) + { + return sprout::fixed::detail::set_union_impl( + first1, + last1, + first2, + last2, + result, + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>() + ); + } + } // namespace fixed + + using sprout::fixed::set_union; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_SET_UNION_HPP diff --git a/sprout/sprout/algorithm/fixed/sort.hpp b/sprout/sprout/algorithm/fixed/sort.hpp new file mode 100644 index 00000000..2c98b663 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/sort.hpp @@ -0,0 +1,194 @@ +#ifndef SPROUT_ALGORITHM_FIXED_SORT_HPP +#define SPROUT_ALGORITHM_FIXED_SORT_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits::value_type const& sort_select_pivot( + Iterator origin, + typename sprout::fixed_container_traits::difference_type start, + typename sprout::fixed_container_traits::difference_type end + ) + { // pivot Iԁi̗vfj + return *(origin + (end + start) / 2); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits::difference_type sort_find_l( + Iterator origin, + Compare comp, + typename sprout::fixed_container_traits::difference_type l, + typename sprout::fixed_container_traits::value_type const& p + ) + { // left ‚ + return comp(*(origin + l), p) ? sort_find_l(origin, comp, l + 1, p) : l; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits::difference_type sort_find_r( + Iterator origin, + Compare comp, + typename sprout::fixed_container_traits::difference_type r, + typename sprout::fixed_container_traits::value_type const& p + ) + { // right ‚ + return comp(p, *(origin + r)) ? sort_find_r(origin, comp, r - 1, p) : r; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type swap_lr( + Container const& cont, + typename sprout::fixed_container_traits::difference_type l, + typename sprout::fixed_container_traits::difference_type r + ); + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type sort_part_l( + Container const& cont, + typename sprout::fixed_container_traits::difference_type start, + Compare comp, + typename sprout::fixed_container_traits::difference_type l + ) + { // \[g + return start < l - 1 ? sort_start(cont, start, l - 1, comp) : sprout::clone(cont); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type sort_part_r( + Container const& cont, + typename sprout::fixed_container_traits::difference_type end, + Compare comp, + typename sprout::fixed_container_traits::difference_type r + ) + { // E\[g + return r + 1 < end ? sort_start(cont, r + 1, end, comp) : sprout::clone(cont); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type sort_part_lr( + Container const& cont, + typename sprout::fixed_container_traits::difference_type start, + typename sprout::fixed_container_traits::difference_type end, + Compare comp, + typename sprout::fixed_container_traits::difference_type l, + typename sprout::fixed_container_traits::difference_type r + ) + { // Eɕă\[g + return sort_part_r(sort_part_l(cont, start, comp, l), end, comp, r); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type sort_next( + Container const& cont, + typename sprout::fixed_container_traits::difference_type start, + typename sprout::fixed_container_traits::difference_type end, + Compare comp, + typename sprout::fixed_container_traits::difference_type l, + typename sprout::fixed_container_traits::difference_type r, + typename sprout::fixed_container_traits::value_type const& p + ) + { // left right rāAEɕă\[g邩A܂̓XbvĂ͈̔͂̃\[g𑱂 + return l >= r + ? sort_part_lr(cont, start, end, comp, l, r) + : sort_lr(sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + l, sprout::fixed_begin(cont) + r), start, end, comp, l + 1, r - 1, p) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type sort_lr( + Container const& cont, + typename sprout::fixed_container_traits::difference_type start, + typename sprout::fixed_container_traits::difference_type end, + Compare comp, + typename sprout::fixed_container_traits::difference_type l, + typename sprout::fixed_container_traits::difference_type r, + typename sprout::fixed_container_traits::value_type const& p + ) + { // left right + return sort_next( + cont, + start, + end, + comp, + sort_find_l(sprout::fixed_begin(cont), comp, l, p), + sort_find_r(sprout::fixed_begin(cont), comp, r, p), + p + ); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type sort_start( + Container const& cont, + typename sprout::fixed_container_traits::difference_type start, + typename sprout::fixed_container_traits::difference_type end, + Compare comp + ) + { // pivot Iă\[gJn + return sort_lr(cont, start, end, comp, start, end, sort_select_pivot(sprout::fixed_begin(cont), start, end)); + } + } // namespace detail + // + // sort + // + template + SPROUT_CONSTEXPR inline typename std::enable_if< + (sprout::fixed_container_traits::fixed_size <= 1), + typename sprout::fixed::result_of::algorithm::type + >::type sort( + Container const& cont, + Compare comp + ) + { + return sprout::clone(cont); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + (sprout::fixed_container_traits::fixed_size > 1), + typename sprout::fixed::result_of::algorithm::type + >::type sort( + Container const& cont, + Compare comp + ) + { + return sprout::fixed::detail::sort_start( + cont, + sprout::fixed_begin_offset(cont), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::end(cont) - 1), + comp + ); + } + // + // sort + // + template + SPROUT_CONSTEXPR inline typename std::enable_if< + (sprout::fixed_container_traits::fixed_size <= 1), + typename sprout::fixed::result_of::algorithm::type + >::type sort( + Container const& cont + ) + { + return sprout::clone(cont); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + (sprout::fixed_container_traits::fixed_size > 1), + typename sprout::fixed::result_of::algorithm::type + >::type sort( + Container const& cont + ) + { + return sprout::fixed::detail::sort_start( + cont, + sprout::fixed_begin_offset(cont), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::end(cont) - 1), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>() + ); + } + } // namespace fixed + + using sprout::fixed::sort; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_SORT_HPP diff --git a/sprout/sprout/algorithm/fixed/sort_heap.hpp b/sprout/sprout/algorithm/fixed/sort_heap.hpp new file mode 100644 index 00000000..1582a890 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/sort_heap.hpp @@ -0,0 +1,75 @@ +#ifndef SPROUT_ALGORITHM_FIXED_SORT_HEAP_HPP +#define SPROUT_ALGORITHM_FIXED_SORT_HEAP_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type sort_heap_impl( + Container const& cont, + Compare comp, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::difference_type size + ) + { + return size < 2 + ? sprout::clone(cont) + : sprout::fixed::detail::sort_heap_impl( + sprout::fixed::detail::pop_heap_impl( + sprout::fixed::swap_element(cont, sprout::begin(cont), sprout::begin(cont) + size - 1), + comp, + offset, + size - 1 + ), + comp, + offset, + size - 1 + ) + ; + } + } // namespace detail + // + // sort_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type sort_heap( + Container const& cont, + Compare comp + ) + { + return sprout::fixed::detail::sort_heap_impl( + cont, + comp, + sprout::fixed_begin_offset(cont), + sprout::size(cont) + ); + } + // + // sort_heap + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type sort_heap( + Container const& cont + ) + { + return sprout::fixed::detail::sort_heap_impl( + cont, + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>(), + sprout::fixed_begin_offset(cont), + sprout::size(cont) + ); + } + } // namespace fixed + + using sprout::fixed::sort_heap; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_SORT_HEAP_HPP diff --git a/sprout/sprout/algorithm/fixed/stable_partition.hpp b/sprout/sprout/algorithm/fixed/stable_partition.hpp new file mode 100644 index 00000000..9448c9e8 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/stable_partition.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_ALGORITHM_FIXED_STABLE_PARTITION_HPP +#define SPROUT_ALGORITHM_FIXED_STABLE_PARTITION_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // stable_partition + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type stable_partition( + Container const& cont, + Predicate pred + ) + { + return sprout::fixed::stable_partition_copy(sprout::begin(cont), sprout::end(cont), cont, pred); + } + } // namespace fixed + + using sprout::fixed::stable_partition; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_STABLE_PARTITION_HPP diff --git a/sprout/sprout/algorithm/fixed/stable_partition_copy.hpp b/sprout/sprout/algorithm/fixed/stable_partition_copy.hpp new file mode 100644 index 00000000..eda39884 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/stable_partition_copy.hpp @@ -0,0 +1,173 @@ +#ifndef SPROUT_ALGORITHM_FIXED_STABLE_PARTITION_COPY_HPP +#define SPROUT_ALGORITHM_FIXED_STABLE_PARTITION_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type stable_partition_copy_impl_4( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type stable_partition_copy_impl_4( + Result const& result, + Args const&... args + ) + { + return stable_partition_copy_impl_4(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); + } + + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type stable_partition_copy_impl_3( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type stable_partition_copy_impl_3( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return first != last && sizeof...(Args) < offset + ? !pred(*first) + ? stable_partition_copy_impl_3(first + 1, last, result, pred, offset, args..., *first) + : stable_partition_copy_impl_3(first + 1, last, result, pred, offset, args...) + : stable_partition_copy_impl_4(result, args...) + ; + } + + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type stable_partition_copy_impl_2( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Iterator origin, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type stable_partition_copy_impl_2( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Iterator origin, + Args const&... args + ) + { + return first != last && sizeof...(Args) < offset + ? pred(*first) + ? stable_partition_copy_impl_2(first + 1, last, result, pred, offset, origin, args..., *first) + : stable_partition_copy_impl_2(first + 1, last, result, pred, offset, origin, args...) + : stable_partition_copy_impl_3(origin, last, result, pred, offset, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type stable_partition_copy_impl_1( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Iterator origin, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type stable_partition_copy_impl_1( + Iterator first, + Iterator last, + Result const& result, + Predicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Iterator origin, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? stable_partition_copy_impl_1(first, last, result, pred, offset, origin, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) + : stable_partition_copy_impl_2(first, last, result, pred, offset + sprout::size(result), origin, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type stable_partition_copy_impl( + Iterator first, + Iterator last, + Result const& result, + Predicate pred + ) + { + return stable_partition_copy_impl_1(first, last, result, pred, sprout::fixed_begin_offset(result), first); + } + } // namespace detail + // + // stable_partition_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type stable_partition_copy( + Iterator first, + Iterator last, + Result const& result, + Predicate pred + ) + { + return sprout::fixed::detail::stable_partition_copy_impl(first, last, result, pred); + } + } // namespace fixed + + using sprout::fixed::stable_partition_copy; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_STABLE_PARTITION_COPY_HPP diff --git a/sprout/sprout/algorithm/fixed/stable_sort.hpp b/sprout/sprout/algorithm/fixed/stable_sort.hpp new file mode 100644 index 00000000..fc595f67 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/stable_sort.hpp @@ -0,0 +1,262 @@ +#ifndef SPROUT_ALGORITHM_FIXED_STABLE_SORT_HPP +#define SPROUT_ALGORITHM_FIXED_STABLE_SORT_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sizeof...(Indexes) != 0 && sizeof...(SortedIndexes) != 0, + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort_impl_4( + Container const& cont, + Compare comp, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple + ); + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type stable_sort_impl_finish( + Container const& cont, + sprout::index_tuple + ) + { + return sprout::remake_clone(result, sprout::size(result), (*(sprout::fixed_begin(cont) + Indexes))...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sizeof...(Indexes) == 0 && sizeof...(SortedIndexes) == 0, + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort_impl_4( + Container const& cont, + Compare comp, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple + ) + { + return comp(*(sprout::fixed_begin(cont) + I1), *(sprout::fixed_begin(cont) + I2)) + ? stable_sort_impl_finish(cont, sprout::index_tuple()) + : stable_sort_impl_finish(cont, sprout::index_tuple()) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sizeof...(Indexes) == 0 && sizeof...(SortedIndexes) != 0, + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort_impl_4( + Container const& cont, + Compare comp, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple + ) + { + return comp(*(sprout::fixed_begin(cont) + I1), *(sprout::fixed_begin(cont) + I2)) + ? stable_sort_impl_finish(cont, sprout::index_tuple()) + : stable_sort_impl_4(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple()) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sizeof...(Indexes) != 0 && sizeof...(SortedIndexes) == 0, + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort_impl_4( + Container const& cont, + Compare comp, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple + ) + { + return comp(*(sprout::fixed_begin(cont) + I1), *(sprout::fixed_begin(cont) + I2)) + ? stable_sort_impl_4(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple<>(), sprout::index_tuple(), sprout::index_tuple()) + : stable_sort_impl_4(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple<>(), sprout::index_tuple(), sprout::index_tuple()) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sizeof...(Indexes) != 0 && sizeof...(SortedIndexes) != 0, + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort_impl_4( + Container const& cont, + Compare comp, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple + ) + { + return comp(*(sprout::fixed_begin(cont) + I1), *(sprout::fixed_begin(cont) + I2)) + ? stable_sort_impl_4(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple<>(), sprout::index_tuple(), sprout::index_tuple()) + : stable_sort_impl_4(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple()) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type stable_sort_impl_3( + Container const& cont, + Compare comp, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple + ) + { + return stable_sort_impl_4(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple<>(), sprout::index_tuple(), sprout::index_tuple()); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + (sizeof...(Indexes) <= 1), + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort_impl_2( + Container const& cont, + Compare comp, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple + ) + { + return stable_sort_impl_finish(cont, sprout::index_tuple()); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + (sizeof...(Indexes) > 1), + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort_impl_2( + Container const& cont, + Compare comp, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple + ) + { + return stable_sort_impl_3(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple()); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sizeof...(Indexes) == 0, + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort_impl_1( + Container const& cont, + Compare comp, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple + ) + { + return I < sprout::fixed_begin_offset(cont) + ? stable_sort_impl_2(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple()) + : I >= sprout::fixed_end_offset(cont) + ? stable_sort_impl_2(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple()) + : stable_sort_impl_2(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple()) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sizeof...(Indexes) != 0, + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort_impl_1( + Container const& cont, + Compare comp, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple, + sprout::index_tuple + ) + { + return I < sprout::fixed_begin_offset(cont) + ? stable_sort_impl_1(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple()) + : I >= sprout::fixed_end_offset(cont) + ? stable_sort_impl_1(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple()) + : stable_sort_impl_1(cont, comp, sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple(), sprout::index_tuple()) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type stable_sort_impl( + Container const& cont, + Compare comp, + sprout::index_tuple + ) + { + return stable_sort_impl_1(cont, comp, sprout::index_tuple(), sprout::index_tuple<>(), sprout::index_tuple<>(), sprout::index_tuple<>()); + } + } // namespace detail + // + // stable_sort + // + template + SPROUT_CONSTEXPR inline typename std::enable_if< + (sprout::fixed_container_traits::fixed_size <= 1), + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort( + Container const& cont, + Compare comp + ) + { + return sprout::clone(cont); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + (sprout::fixed_container_traits::fixed_size > 1), + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort( + Container const& cont, + Compare comp + ) + { + return sprout::fixed::detail::stable_sort_impl( + cont, + comp, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type() + ); + } + // + // stable_sort + // + template + SPROUT_CONSTEXPR inline typename std::enable_if< + (sprout::fixed_container_traits::fixed_size <= 1), + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort( + Container const& cont + ) + { + return sprout::clone(cont); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + (sprout::fixed_container_traits::fixed_size > 1), + typename sprout::fixed::result_of::algorithm::type + >::type stable_sort( + Container const& cont + ) + { + return sprout::fixed::detail::stable_sort_impl( + cont, + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less::value_type>(), + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type() + ); + } + } // namespace fixed + + using sprout::fixed::stable_sort; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_STABLE_SORT_HPP diff --git a/sprout/sprout/algorithm/fixed/swap_element.hpp b/sprout/sprout/algorithm/fixed/swap_element.hpp new file mode 100644 index 00000000..aa038a91 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/swap_element.hpp @@ -0,0 +1,29 @@ +#ifndef SPROUT_ALGORITHM_FIXED_SWAP_ELEMENT_HPP +#define SPROUT_ALGORITHM_FIXED_SWAP_ELEMENT_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // swap_element + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type swap_element( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos1, + typename sprout::fixed_container_traits::const_iterator pos2 + ) + { + return sprout::fixed::swap_element_copy(sprout::begin(cont), sprout::end(cont), cont, pos1, pos2); + } + } // namespace fixed + + using sprout::fixed::swap_element; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_SWAP_ELEMENT_HPP diff --git a/sprout/sprout/algorithm/fixed/swap_element_copy.hpp b/sprout/sprout/algorithm/fixed/swap_element_copy.hpp new file mode 100644 index 00000000..26512088 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/swap_element_copy.hpp @@ -0,0 +1,71 @@ +#ifndef SPROUT_ALGORITHM_FIXED_SWAP_ELEMENT_COPY_HPP +#define SPROUT_ALGORITHM_FIXED_SWAP_ELEMENT_COPY_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type swap_element_copy_impl( + Iterator first, + Iterator last, + Result const& result, + sprout::index_tuple, + Iterator pos1, + Iterator pos2, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, + typename sprout::fixed_container_traits::size_type input_size + ) + { + return sprout::remake_clone( + result, + sprout::size(result), + (Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size + ? first + Indexes - offset == pos1 + ? *pos2 + : first + Indexes - offset == pos2 + ? *pos1 + : *(first + Indexes - offset) + : *(sprout::fixed_begin(result) + Indexes) + )... + ); + } + } // namespace detail + // + // swap_element_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type swap_element_copy( + Iterator first, + Iterator last, + Result const& result, + Iterator pos1, + Iterator pos2 + ) + { + return sprout::fixed::detail::swap_element_copy_impl( + first, + last, + result, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type(), + pos1, + pos2, + sprout::fixed_begin_offset(result), + sprout::size(result), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last) + ); + } + } // namespace fixed + + using sprout::fixed::swap_element_copy; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_SWAP_ELEMENT_COPY_HPP diff --git a/sprout/sprout/algorithm/fixed/transform.hpp b/sprout/sprout/algorithm/fixed/transform.hpp new file mode 100644 index 00000000..37526106 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/transform.hpp @@ -0,0 +1,113 @@ +#ifndef SPROUT_ALGORITHM_FIXED_TRANSFORM_HPP +#define SPROUT_ALGORITHM_FIXED_TRANSFORM_HPP + +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type transform_impl( + Iterator first, + Iterator last, + Result const& result, + sprout::index_tuple, + UnaryOperation op, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, + typename sprout::fixed_container_traits::size_type input_size + ) + { + return sprout::remake_clone( + result, + sprout::size(result), + (Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size + ? op(*(first + Indexes - offset)) + : *(sprout::fixed_begin(result) + Indexes) + )... + ); + } + } // namespace detail + // + // transform + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type transform( + Iterator first, + Iterator last, + Result const& result, + UnaryOperation op + ) + { + return sprout::fixed::detail::transform_impl( + first, + last, + result, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type(), + op, + sprout::fixed_begin_offset(result), + sprout::size(result), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last) + ); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type transform_impl( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Result const& result, + sprout::index_tuple, + BinaryOperation op, + typename sprout::fixed_container_traits::difference_type offset, + typename sprout::fixed_container_traits::size_type size, + typename sprout::fixed_container_traits::size_type input_size + ) + { + return sprout::remake_clone( + result, + sprout::size(result), + (Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size + ? op(*(first1 + Indexes - offset), *(first2 + Indexes - offset)) + : *(sprout::fixed_begin(result) + Indexes) + )... + ); + } + } // namespace detail + // + // transform + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type transform( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Result const& result, + BinaryOperation op + ) + { + return sprout::fixed::detail::transform_impl( + first1, + last1, + first2, + result, + typename sprout::index_range<0, sprout::fixed_container_traits::fixed_size>::type(), + op, + sprout::fixed_begin_offset(result), + sprout::size(result), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first1, last1) + ); + } + } // namespace fixed + + using sprout::fixed::transform; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_TRANSFORM_HPP diff --git a/sprout/sprout/algorithm/fixed/unique.hpp b/sprout/sprout/algorithm/fixed/unique.hpp new file mode 100644 index 00000000..65ec6334 --- /dev/null +++ b/sprout/sprout/algorithm/fixed/unique.hpp @@ -0,0 +1,38 @@ +#ifndef SPROUT_ALGORITHM_FIXED_UNIQUE_HPP +#define SPROUT_ALGORITHM_FIXED_UNIQUE_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + // + // unique + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type unique( + Container const& cont + ) + { + return sprout::fixed::unique_copy(sprout::begin(cont), sprout::end(cont), cont); + } + + // + // unique + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type unique( + Container const& cont, + BinaryPredicate pred + ) + { + return sprout::fixed::unique_copy(sprout::begin(cont), sprout::end(cont), cont, pred); + } + } // namespace fixed + + using sprout::fixed::unique; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_UNIQUE_HPP diff --git a/sprout/sprout/algorithm/fixed/unique_copy.hpp b/sprout/sprout/algorithm/fixed/unique_copy.hpp new file mode 100644 index 00000000..b819187d --- /dev/null +++ b/sprout/sprout/algorithm/fixed/unique_copy.hpp @@ -0,0 +1,224 @@ +#ifndef SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP +#define SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type unique_copy_impl_3( + Result const& result, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type unique_copy_impl_3( + Result const& result, + Args const&... args + ) + { + return unique_copy_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args) + 1, + typename sprout::fixed::result_of::algorithm::type + >::type unique_copy_impl_2( + Iterator first, + Iterator last, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset, + Head const& head, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args) + 1, + typename sprout::fixed::result_of::algorithm::type + >::type unique_copy_impl_2( + Iterator first, + Iterator last, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset, + Head const& head, + Args const&... args + ) + { + return first != last && sizeof...(Args) + 1 < offset + ? !(head == *first) + ? unique_copy_impl_2(first + 1, last, result, offset, *first, args..., head) + : unique_copy_impl_2(first + 1, last, result, offset, head, args...) + : unique_copy_impl_3(result, args..., head) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type unique_copy_impl_1( + Iterator first, + Iterator last, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type unique_copy_impl_1( + Iterator first, + Iterator last, + Result const& result, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? unique_copy_impl_1(first, last, result, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) + : unique_copy_impl_2(first + 1, last, result, offset + sprout::size(result), *first, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type unique_copy_impl( + Iterator first, + Iterator last, + Result const& result + ) + { + return unique_copy_impl_1(first, last, result, sprout::fixed_begin_offset(result)); + } + } // namespace detail + // + // unique_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type unique_copy( + Iterator first, + Iterator last, + Result const& result + ) + { + return sprout::fixed::detail::unique_copy_impl(first, last, result); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args) + 1, + typename sprout::fixed::result_of::algorithm::type + >::type unique_copy_impl_2( + Iterator first, + Iterator last, + Result const& result, + BinaryPredicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Head const& head, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args) + 1, + typename sprout::fixed::result_of::algorithm::type + >::type unique_copy_impl_2( + Iterator first, + Iterator last, + Result const& result, + BinaryPredicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Head const& head, + Args const&... args + ) + { + return first != last && sizeof...(Args) + 1 < offset + ? !pred(head, *first) + ? unique_copy_impl_2(first + 1, last, result, pred, offset, *first, args..., head) + : unique_copy_impl_2(first + 1, last, result, pred, offset, head, args...) + : unique_copy_impl_3(result, args..., head) + ; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size == sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type unique_copy_impl_1( + Iterator first, + Iterator last, + Result const& result, + BinaryPredicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sprout::remake_clone(result, sprout::size(result), args...); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sprout::fixed_container_traits::fixed_size != sizeof...(Args), + typename sprout::fixed::result_of::algorithm::type + >::type unique_copy_impl_1( + Iterator first, + Iterator last, + Result const& result, + BinaryPredicate pred, + typename sprout::fixed_container_traits::difference_type offset, + Args const&... args + ) + { + return sizeof...(Args) < offset + ? unique_copy_impl_1(first, last, result, pred, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) + : unique_copy_impl_2(first + 1, last, result, pred, offset + sprout::size(result), *first, args...) + ; + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type unique_copy_impl( + Iterator first, + Iterator last, + Result const& result, + BinaryPredicate pred + ) + { + return unique_copy_impl_1(first, last, result, pred, sprout::fixed_begin_offset(result)); + } + } // namespace detail + // + // unique_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type unique_copy( + Iterator first, + Iterator last, + Result const& result, + BinaryPredicate pred + ) + { + return sprout::fixed::detail::unique_copy_impl(first, last, result, pred); + } + } // namespace fixed + + using sprout::fixed::unique_copy; +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP diff --git a/sprout/sprout/algorithm/generate.hpp b/sprout/sprout/algorithm/generate.hpp new file mode 100644 index 00000000..dc5d5870 --- /dev/null +++ b/sprout/sprout/algorithm/generate.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_GENERATE_HPP +#define SPROUT_ALGORITHM_GENERATE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_GENERATE_HPP diff --git a/sprout/sprout/algorithm/generate_n.hpp b/sprout/sprout/algorithm/generate_n.hpp new file mode 100644 index 00000000..4801cd1e --- /dev/null +++ b/sprout/sprout/algorithm/generate_n.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_GENERATE_N_HPP +#define SPROUT_ALGORITHM_GENERATE_N_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_GENERATE_N_HPP diff --git a/sprout/sprout/algorithm/inplace_merge.hpp b/sprout/sprout/algorithm/inplace_merge.hpp new file mode 100644 index 00000000..a7f3716b --- /dev/null +++ b/sprout/sprout/algorithm/inplace_merge.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_INPLACE_MERGE_HPP +#define SPROUT_ALGORITHM_INPLACE_MERGE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_INPLACE_MERGE_HPP diff --git a/sprout/sprout/algorithm/make_heap.hpp b/sprout/sprout/algorithm/make_heap.hpp new file mode 100644 index 00000000..e8b13842 --- /dev/null +++ b/sprout/sprout/algorithm/make_heap.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_MAKE_HEAP_HPP +#define SPROUT_ALGORITHM_MAKE_HEAP_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_MAKE_HEAP_HPP diff --git a/sprout/sprout/algorithm/make_partial_heap.hpp b/sprout/sprout/algorithm/make_partial_heap.hpp new file mode 100644 index 00000000..897f226b --- /dev/null +++ b/sprout/sprout/algorithm/make_partial_heap.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_MAKE_PARTIAL_HEAP_HPP +#define SPROUT_ALGORITHM_MAKE_PARTIAL_HEAP_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_MAKE_PARTIAL_HEAP_HPP diff --git a/sprout/sprout/algorithm/merge.hpp b/sprout/sprout/algorithm/merge.hpp new file mode 100644 index 00000000..c204afa8 --- /dev/null +++ b/sprout/sprout/algorithm/merge.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_MERGE_HPP +#define SPROUT_ALGORITHM_MERGE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_MERGE_HPP diff --git a/sprout/sprout/algorithm/nth_element.hpp b/sprout/sprout/algorithm/nth_element.hpp new file mode 100644 index 00000000..8a2b4f00 --- /dev/null +++ b/sprout/sprout/algorithm/nth_element.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_NTH_ELEMENT_HPP +#define SPROUT_ALGORITHM_NTH_ELEMENT_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_NTH_ELEMENT_HPP diff --git a/sprout/sprout/algorithm/partial_sort.hpp b/sprout/sprout/algorithm/partial_sort.hpp new file mode 100644 index 00000000..a0d391c8 --- /dev/null +++ b/sprout/sprout/algorithm/partial_sort.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_PARTIAL_SORT_HPP +#define SPROUT_ALGORITHM_PARTIAL_SORT_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_PARTIAL_SORT_HPP diff --git a/sprout/sprout/algorithm/partition.hpp b/sprout/sprout/algorithm/partition.hpp new file mode 100644 index 00000000..3ba477d7 --- /dev/null +++ b/sprout/sprout/algorithm/partition.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_PARTITION_HPP +#define SPROUT_ALGORITHM_PARTITION_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_PARTITION_HPP diff --git a/sprout/sprout/algorithm/partition_copy.hpp b/sprout/sprout/algorithm/partition_copy.hpp new file mode 100644 index 00000000..544f5d4b --- /dev/null +++ b/sprout/sprout/algorithm/partition_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_PARTITION_COPY_HPP +#define SPROUT_ALGORITHM_PARTITION_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_PARTITION_COPY_HPP diff --git a/sprout/sprout/algorithm/pop_heap.hpp b/sprout/sprout/algorithm/pop_heap.hpp new file mode 100644 index 00000000..7f7335f8 --- /dev/null +++ b/sprout/sprout/algorithm/pop_heap.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_POP_HEAP_HPP +#define SPROUT_ALGORITHM_POP_HEAP_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_POP_HEAP_HPP diff --git a/sprout/sprout/algorithm/push_heap.hpp b/sprout/sprout/algorithm/push_heap.hpp new file mode 100644 index 00000000..c5a9a0c8 --- /dev/null +++ b/sprout/sprout/algorithm/push_heap.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_PUSH_HEAP_HPP +#define SPROUT_ALGORITHM_PUSH_HEAP_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_PUSH_HEAP_HPP diff --git a/sprout/sprout/algorithm/remove.hpp b/sprout/sprout/algorithm/remove.hpp new file mode 100644 index 00000000..08944e01 --- /dev/null +++ b/sprout/sprout/algorithm/remove.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_REMOVE_HPP +#define SPROUT_ALGORITHM_REMOVE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_REMOVE_HPP diff --git a/sprout/sprout/algorithm/remove_copy.hpp b/sprout/sprout/algorithm/remove_copy.hpp new file mode 100644 index 00000000..1d97618e --- /dev/null +++ b/sprout/sprout/algorithm/remove_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_REMOVE_COPY_HPP +#define SPROUT_ALGORITHM_REMOVE_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_REMOVE_COPY_HPP diff --git a/sprout/sprout/algorithm/remove_copy_if.hpp b/sprout/sprout/algorithm/remove_copy_if.hpp new file mode 100644 index 00000000..5a2a49d1 --- /dev/null +++ b/sprout/sprout/algorithm/remove_copy_if.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_REMOVE_COPY_IF_HPP +#define SPROUT_ALGORITHM_REMOVE_COPY_IF_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_REMOVE_COPY_IF_HPP diff --git a/sprout/sprout/algorithm/remove_if.hpp b/sprout/sprout/algorithm/remove_if.hpp new file mode 100644 index 00000000..6ed06a88 --- /dev/null +++ b/sprout/sprout/algorithm/remove_if.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_REMOVE_IF_HPP +#define SPROUT_ALGORITHM_REMOVE_IF_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_REMOVE_IF_HPP diff --git a/sprout/sprout/algorithm/replace.hpp b/sprout/sprout/algorithm/replace.hpp new file mode 100644 index 00000000..6b433b77 --- /dev/null +++ b/sprout/sprout/algorithm/replace.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_REPLACE_HPP +#define SPROUT_ALGORITHM_REPLACE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_REPLACE_HPP diff --git a/sprout/sprout/algorithm/replace_copy.hpp b/sprout/sprout/algorithm/replace_copy.hpp new file mode 100644 index 00000000..d4f83183 --- /dev/null +++ b/sprout/sprout/algorithm/replace_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_REPLACE_COPY_HPP +#define SPROUT_ALGORITHM_REPLACE_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_REPLACE_COPY_HPP diff --git a/sprout/sprout/algorithm/replace_copy_if.hpp b/sprout/sprout/algorithm/replace_copy_if.hpp new file mode 100644 index 00000000..2e21e74e --- /dev/null +++ b/sprout/sprout/algorithm/replace_copy_if.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_REPLACE_COPY_IF_HPP +#define SPROUT_ALGORITHM_REPLACE_COPY_IF_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_REPLACE_COPY_IF_HPP diff --git a/sprout/sprout/algorithm/replace_if.hpp b/sprout/sprout/algorithm/replace_if.hpp new file mode 100644 index 00000000..91b8cec4 --- /dev/null +++ b/sprout/sprout/algorithm/replace_if.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_REPLACE_IF_HPP +#define SPROUT_ALGORITHM_REPLACE_IF_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_REPLACE_IF_HPP diff --git a/sprout/sprout/algorithm/reverse.hpp b/sprout/sprout/algorithm/reverse.hpp new file mode 100644 index 00000000..b8cd2089 --- /dev/null +++ b/sprout/sprout/algorithm/reverse.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_REVERSE_HPP +#define SPROUT_ALGORITHM_REVERSE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_REVERSE_HPP diff --git a/sprout/sprout/algorithm/reverse_copy.hpp b/sprout/sprout/algorithm/reverse_copy.hpp new file mode 100644 index 00000000..89e858ef --- /dev/null +++ b/sprout/sprout/algorithm/reverse_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_REVERSE_COPY_HPP +#define SPROUT_ALGORITHM_REVERSE_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_REVERSE_COPY_HPP diff --git a/sprout/sprout/algorithm/rotate.hpp b/sprout/sprout/algorithm/rotate.hpp new file mode 100644 index 00000000..c545bfa4 --- /dev/null +++ b/sprout/sprout/algorithm/rotate.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_ROTATE_HPP +#define SPROUT_ALGORITHM_ROTATE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_ROTATE_HPP diff --git a/sprout/sprout/algorithm/rotate_copy.hpp b/sprout/sprout/algorithm/rotate_copy.hpp new file mode 100644 index 00000000..5821e534 --- /dev/null +++ b/sprout/sprout/algorithm/rotate_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_ROTATE_COPY_HPP +#define SPROUT_ALGORITHM_ROTATE_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_ROTATE_COPY_HPP diff --git a/sprout/sprout/algorithm/set_difference.hpp b/sprout/sprout/algorithm/set_difference.hpp new file mode 100644 index 00000000..fc61023d --- /dev/null +++ b/sprout/sprout/algorithm/set_difference.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_SET_DIFFERENCE_HPP +#define SPROUT_ALGORITHM_SET_DIFFERENCE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_SET_DIFFERENCE_HPP diff --git a/sprout/sprout/algorithm/set_intersection.hpp b/sprout/sprout/algorithm/set_intersection.hpp new file mode 100644 index 00000000..32376526 --- /dev/null +++ b/sprout/sprout/algorithm/set_intersection.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_SET_INTERSECTION_HPP +#define SPROUT_ALGORITHM_SET_INTERSECTION_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_SET_INTERSECTION_HPP diff --git a/sprout/sprout/algorithm/set_symmetric_difference.hpp b/sprout/sprout/algorithm/set_symmetric_difference.hpp new file mode 100644 index 00000000..c918a310 --- /dev/null +++ b/sprout/sprout/algorithm/set_symmetric_difference.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_SET_SYMMETRIC_DIFFERENCE_HPP +#define SPROUT_ALGORITHM_SET_SYMMETRIC_DIFFERENCE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_SET_SYMMETRIC_DIFFERENCE_HPP diff --git a/sprout/sprout/algorithm/set_union.hpp b/sprout/sprout/algorithm/set_union.hpp new file mode 100644 index 00000000..c3b2fd7e --- /dev/null +++ b/sprout/sprout/algorithm/set_union.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_SET_UNION_HPP +#define SPROUT_ALGORITHM_SET_UNION_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_SET_UNION_HPP diff --git a/sprout/sprout/algorithm/sort.hpp b/sprout/sprout/algorithm/sort.hpp new file mode 100644 index 00000000..f82dea03 --- /dev/null +++ b/sprout/sprout/algorithm/sort.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_SORT_HPP +#define SPROUT_ALGORITHM_SORT_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_SORT_HPP diff --git a/sprout/sprout/algorithm/sort_heap.hpp b/sprout/sprout/algorithm/sort_heap.hpp new file mode 100644 index 00000000..6cdaa60b --- /dev/null +++ b/sprout/sprout/algorithm/sort_heap.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_SORT_HEAP_HPP +#define SPROUT_ALGORITHM_SORT_HEAP_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_SORT_HEAP_HPP diff --git a/sprout/sprout/algorithm/stable_partition.hpp b/sprout/sprout/algorithm/stable_partition.hpp new file mode 100644 index 00000000..735e0cca --- /dev/null +++ b/sprout/sprout/algorithm/stable_partition.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_STABLE_PARTITION_HPP +#define SPROUT_ALGORITHM_STABLE_PARTITION_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_STABLE_PARTITION_HPP diff --git a/sprout/sprout/algorithm/stable_partition_copy.hpp b/sprout/sprout/algorithm/stable_partition_copy.hpp new file mode 100644 index 00000000..002a5dbc --- /dev/null +++ b/sprout/sprout/algorithm/stable_partition_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_STABLE_PARTITION_COPY_HPP +#define SPROUT_ALGORITHM_STABLE_PARTITION_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_STABLE_PARTITION_COPY_HPP diff --git a/sprout/sprout/algorithm/stable_sort.hpp b/sprout/sprout/algorithm/stable_sort.hpp new file mode 100644 index 00000000..ccc474ae --- /dev/null +++ b/sprout/sprout/algorithm/stable_sort.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_STABLE_SORT_HPP +#define SPROUT_ALGORITHM_STABLE_SORT_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_STABLE_SORT_HPP diff --git a/sprout/sprout/algorithm/swap_element.hpp b/sprout/sprout/algorithm/swap_element.hpp new file mode 100644 index 00000000..3da2f8fe --- /dev/null +++ b/sprout/sprout/algorithm/swap_element.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_SWAP_ELEMENT_HPP +#define SPROUT_ALGORITHM_SWAP_ELEMENT_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_SWAP_ELEMENT_HPP diff --git a/sprout/sprout/algorithm/swap_element_copy.hpp b/sprout/sprout/algorithm/swap_element_copy.hpp new file mode 100644 index 00000000..c8aee0bc --- /dev/null +++ b/sprout/sprout/algorithm/swap_element_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_SWAP_ELEMENT_COPY_HPP +#define SPROUT_ALGORITHM_SWAP_ELEMENT_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_SWAP_ELEMENT_COPY_HPP diff --git a/sprout/sprout/algorithm/transform.hpp b/sprout/sprout/algorithm/transform.hpp new file mode 100644 index 00000000..cbd3eea9 --- /dev/null +++ b/sprout/sprout/algorithm/transform.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_TRANSFORM_HPP +#define SPROUT_ALGORITHM_TRANSFORM_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_TRANSFORM_HPP diff --git a/sprout/sprout/algorithm/unique.hpp b/sprout/sprout/algorithm/unique.hpp new file mode 100644 index 00000000..4dc17e8a --- /dev/null +++ b/sprout/sprout/algorithm/unique.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_UNIQUE_HPP +#define SPROUT_ALGORITHM_UNIQUE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_UNIQUE_HPP diff --git a/sprout/sprout/algorithm/unique_copy.hpp b/sprout/sprout/algorithm/unique_copy.hpp new file mode 100644 index 00000000..73620ba5 --- /dev/null +++ b/sprout/sprout/algorithm/unique_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_ALGORITHM_UNIQUE_COPY_HPP +#define SPROUT_ALGORITHM_UNIQUE_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_UNIQUE_COPY_HPP diff --git a/sprout/sprout/array.hpp b/sprout/sprout/array.hpp new file mode 100644 index 00000000..60b06f0b --- /dev/null +++ b/sprout/sprout/array.hpp @@ -0,0 +1,291 @@ +#ifndef SPROUT_ARRAY_HPP +#define SPROUT_ARRAY_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + // + // array + // + template + class array { + public: + typedef T value_type; + typedef T* iterator; + typedef T const* const_iterator; + typedef T& reference; + typedef T const& const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef T* pointer; + typedef T const* const_pointer; + typedef sprout::detail::reverse_iterator reverse_iterator; + typedef sprout::detail::reverse_iterator const_reverse_iterator; + public: + SPROUT_STATIC_CONSTEXPR size_type static_size = N; + SPROUT_STATIC_CONSTEXPR size_type fixed_size = static_size; + public: + T elems[N ? N : 1]; + public: + SPROUT_CONSTEXPR size_type size() const SPROUT_NOEXCEPT { + return N; + } + SPROUT_CONSTEXPR bool empty() const SPROUT_NOEXCEPT { + return N != 0; + } + SPROUT_CONSTEXPR size_type max_size() const SPROUT_NOEXCEPT { + return size(); + } + void rangecheck(size_type i) const { + if (i >= size()) { + throw std::out_of_range("array<>: index out of range"); + } + } + iterator begin() SPROUT_NOEXCEPT { + return elems; + } + SPROUT_CONSTEXPR const_iterator begin() const SPROUT_NOEXCEPT { + return elems; + } + SPROUT_CONSTEXPR const_iterator cbegin() const SPROUT_NOEXCEPT { + return elems; + } + iterator end() SPROUT_NOEXCEPT { + return elems + size(); + } + SPROUT_CONSTEXPR const_iterator end() const SPROUT_NOEXCEPT { + return elems + size(); + } + SPROUT_CONSTEXPR const_iterator cend() const SPROUT_NOEXCEPT { + return elems + size(); + } + reverse_iterator rbegin() SPROUT_NOEXCEPT { + return reverse_iterator(begin()); + } + SPROUT_CONSTEXPR const_reverse_iterator rbegin() const SPROUT_NOEXCEPT { + return const_reverse_iterator(begin()); + } + SPROUT_CONSTEXPR const_reverse_iterator crbegin() const SPROUT_NOEXCEPT { + return const_reverse_iterator(begin()); + } + reverse_iterator rend() SPROUT_NOEXCEPT { + return reverse_iterator(end()); + } + SPROUT_CONSTEXPR const_reverse_iterator rend() const SPROUT_NOEXCEPT { + return const_reverse_iterator(end()); + } + SPROUT_CONSTEXPR const_reverse_iterator crend() const SPROUT_NOEXCEPT { + return const_reverse_iterator(end()); + } + reference operator[](size_type i) { + return elems[i]; + } + SPROUT_CONSTEXPR const_reference operator[](size_type i) const { + return elems[i]; + } + reference at(size_type i) { + rangecheck(i); + return elems[i]; + } + const_reference at(size_type i) const { + rangecheck(i); + return elems[i]; + } + reference front() { + return elems[0]; + } + SPROUT_CONSTEXPR const_reference front() const { + return elems[0]; + } + reference back() { + return elems[size() - 1]; + } + SPROUT_CONSTEXPR const_reference back() const { + return elems[size() - 1]; + } + pointer data() SPROUT_NOEXCEPT { + return elems; + } + SPROUT_CONSTEXPR const_pointer data() const SPROUT_NOEXCEPT { + return elems; + } + pointer c_array() SPROUT_NOEXCEPT { + return elems; + } + void assign(const_reference value) { + fill(value); + } + void fill(const_reference value) { + std::fill_n(begin(), size(), value); + } + void swap(array& other) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::swap(std::declval(), std::declval()))) { + std::swap_ranges(other.begin(), other.end(), begin()); + } + template + array& operator=(array const& rhs) { + std::copy(rhs.begin(), rhs.end(), begin()); + return *this; + } + template + array& operator=(array&& rhs) { + std::move(rhs.begin(), rhs.end(), begin()); + return *this; + } + }; + template + SPROUT_CONSTEXPR inline bool operator==(sprout::array const& lhs, sprout::array const& rhs) { + return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::equal(lhs.begin(), lhs.end(), rhs.begin()); + } + template + SPROUT_CONSTEXPR inline bool operator!=(sprout::array const& lhs, sprout::array const& rhs) { + return !(lhs == rhs); + } + template + SPROUT_CONSTEXPR inline bool operator<(sprout::array const& lhs, sprout::array const& rhs) { + return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + } + template + SPROUT_CONSTEXPR inline bool operator>(sprout::array const& lhs, sprout::array const& rhs) { + return rhs < lhs; + } + template + SPROUT_CONSTEXPR inline bool operator<=(sprout::array const& lhs, sprout::array const& rhs) { + return !(rhs < lhs); + } + template + SPROUT_CONSTEXPR inline bool operator>=(sprout::array const& lhs, sprout::array const& rhs) { + return !(lhs < rhs); + } + + // + // swap + // + template + SPROUT_CONSTEXPR inline void swap(sprout::array& lhs, sprout::array& rhs) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) { + lhs.swap(rhs); + } + + // + // rebind_fixed_size + // + template + struct rebind_fixed_size > { + public: + template >::size_type S> + struct apply { + public: + typedef sprout::array type; + }; + }; + + namespace detail { + template + struct is_array_impl { + public: + typedef std::integral_constant type; + SPROUT_STATIC_CONSTEXPR bool value = type::value; + }; + template + struct is_array_impl< + T, + typename std::enable_if< + std::is_same< + T, + sprout::array + >::value + >::type + > { + public: + typedef std::integral_constant type; + SPROUT_STATIC_CONSTEXPR bool value = type::value; + }; + } // namespace detail + // + // is_array + // + template + struct is_array + : public sprout::detail::is_array_impl + {}; + + // + // make_array + // + template + SPROUT_CONSTEXPR inline sprout::array make_array(T const& head, Tail const&... tail) { + return sprout::array{head, tail...}; + } + template + SPROUT_CONSTEXPR inline sprout::array make_array() { + return sprout::array{}; + } + + namespace detail { + template + SPROUT_CONSTEXPR inline sprout::array to_array_impl( + T const (& arr)[N], + sprout::index_tuple + ) + { + return sprout::array{arr[Indexes]...}; + } + } // namespace detail + // + // to_array + // + template + SPROUT_CONSTEXPR inline sprout::array to_array(T const (& arr)[N]) { + return sprout::detail::to_array_impl(arr, typename sprout::index_range<0, N>::type()); + } +} // namespace sprout + +namespace std { + // + // tuple_size + // + template + struct tuple_size > { + public: + typedef std::integral_constant type; + SPROUT_STATIC_CONSTEXPR std::size_t value = type::value; + }; + + // + // tuple_element + // + template + struct tuple_element > { + public: + static_assert(I < N, "tuple_element<>: index out of range"); + typedef T type; + }; + + // + // get + // + template + T& get(sprout::array& arr) SPROUT_NOEXCEPT { + static_assert(I < N, "tuple_element<>: index out of range"); + return arr[I]; + } + template + SPROUT_CONSTEXPR T const& get(sprout::array const& arr) SPROUT_NOEXCEPT { + static_assert(I < N, "tuple_element<>: index out of range"); + return arr[I]; + } + template + T&& get(sprout::array&& arr) SPROUT_NOEXCEPT { + return std::move(get(arr)); + } +} // namespace std + +#endif // #ifndef SPROUT_ARRAY_HPP diff --git a/sprout/sprout/config.hpp b/sprout/sprout/config.hpp new file mode 100644 index 00000000..e17a8f23 --- /dev/null +++ b/sprout/sprout/config.hpp @@ -0,0 +1,32 @@ +#ifndef SPROUT_CONFIG_HPP +#define SPROUT_CONFIG_HPP + +#ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR +# define SPROUT_CONSTEXPR constexpr +# define SPROUT_STATIC_CONSTEXPR static constexpr +#else // #ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR +# define SPROUT_CONSTEXPR +# define SPROUT_STATIC_CONSTEXPR static const +#endif // #ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR + +#ifndef SPROUT_CONFIG_DISABLE_NOEXCEPT +# define SPROUT_NOEXCEPT noexcept +# define SPROUT_NOEXCEPT_EXPR(EXPR) noexcept(EXPR) +#else // #ifndef SPROUT_CONFIG_DISABLE_NOEXCEPT +# define SPROUT_NOEXCEPT +# define SPROUT_NOEXCEPT_EXPR(EXPR) +#endif // #ifndef SPROUT_CONFIG_DISABLE_NOEXCEPT + +#ifndef SPROUT_CONFIG_USE_SSCRISK_CEL +# define HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL +# define HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +# define HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL +# define NS_SSCRISK_CEL_OR_SPROUT_DETAIL sprout::detail +#else // #ifndef SPROUT_CONFIG_USE_SSCRISK_CEL +# define HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL +# define HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +# define HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL +# define NS_SSCRISK_CEL_OR_SPROUT_DETAIL sscrisk::cel +#endif // #ifndef SPROUT_CONFIG_USE_SSCRISK_CEL + +#endif // #ifndef SPROUT_CONFIG_HPP diff --git a/sprout/sprout/detail/algorithm.hpp b/sprout/sprout/detail/algorithm.hpp new file mode 100644 index 00000000..e7b36f32 --- /dev/null +++ b/sprout/sprout/detail/algorithm.hpp @@ -0,0 +1,131 @@ +#ifndef SPROUT_DETAIL_ALGORITHM_HPP +#define SPROUT_DETAIL_ALGORITHM_HPP + +#include +#include + +namespace sprout { + namespace detail { + // + // min + // + template + SPROUT_CONSTEXPR T const& min(T const& a, T const& b) { + return b < a ? b : a; + } + template + SPROUT_CONSTEXPR T const& min(T const& a, T const& b, Compare comp) { + return comp(b, a) ? b : a; + } + + // + // max + // + template + SPROUT_CONSTEXPR T const& max(T const& a, T const& b) { + return a < b ? b : a; + } + template + SPROUT_CONSTEXPR T const& max(T const& a, T const& b, Compare comp) { + return comp(a, b) ? b : a; + } + + // + // count + // + template + SPROUT_CONSTEXPR typename std::iterator_traits::difference_type count( + Iterator first, + Iterator last, + T const & value + ) + { + return first == last + ? 0 + : (*first == value ? 1 : 0) + sprout::detail::count(first + 1, last, value) + ; + } + + // + // count_if + // + template + SPROUT_CONSTEXPR typename std::iterator_traits::difference_type count_if( + Iterator first, + Iterator last, + Predicate pred + ) + { + return first == last + ? 0 + : (pred(*first) ? 1 : 0) + sprout::detail::count_if(first + 1, last, pred); + } + + // + // equal + // + template + SPROUT_CONSTEXPR bool equal( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2 + ) + { + return first1 == last1 + ? true + : *first1 == *first2 && sprout::detail::equal(first1 + 1, last1, first2 + 1) + ; + } + template + SPROUT_CONSTEXPR bool equal( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Predicate pred + ) + { + return first1 == last1 + ? true + : pred(*first1, *first2) && sprout::detail::equal(first1 + 1, last1, first2 + 1, pred); + } + + // + // lexicographical_compare + // + template + SPROUT_CONSTEXPR bool lexicographical_compare( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2 + ) + { + return first2 == last2 + ? false + : first1 == last1 || *first1 < *first2 + ? true + : *first2 < *first1 + ? false + : sprout::detail::lexicographical_compare(first1 + 1, last1, first2 + 1, last2); + } + template + SPROUT_CONSTEXPR bool lexicographical_compare( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Compare comp + ) + { + return first2 == last2 + ? false + : first1 == last1 || comp(*first1, *first2) + ? true + : comp(*first2, *first1) + ? false + : sprout::detail::lexicographical_compare(first1 + 1, last1, first2 + 1, last2, comp); + } + } // namespace detail +} // namespace sprout + +#endif // #ifndef SPROUT_DETAIL_ALGORITHM_HPP diff --git a/sprout/sprout/detail/functional.hpp b/sprout/sprout/detail/functional.hpp new file mode 100644 index 00000000..4f66da6e --- /dev/null +++ b/sprout/sprout/detail/functional.hpp @@ -0,0 +1,24 @@ +#ifndef SPROUT_DETAIL_FUNCTIONAL_HPP +#define SPROUT_DETAIL_FUNCTIONAL_HPP + +#include +#include + +namespace sprout { + namespace detail { + // + // less + // + template + class less + : public std::binary_function + { + public: + SPROUT_CONSTEXPR bool operator()(T const& lhs, T const& rhs) const { + return lhs < rhs; + } + }; + } // namespace detail +} // namespace sprout + +#endif // #ifndef SPROUT_DETAIL_FUNCTIONAL_HPP diff --git a/sprout/sprout/detail/if.hpp b/sprout/sprout/detail/if.hpp new file mode 100644 index 00000000..0c6725ea --- /dev/null +++ b/sprout/sprout/detail/if.hpp @@ -0,0 +1,30 @@ +#ifndef SPROUT_DETAIL_IF_HPP +#define SPROUT_DETAIL_IF_HPP + +#include + +namespace sprout { + namespace detail { + // + // if_c + // + template + struct if_c { + typedef T1 type; + }; + template + struct if_c { + typedef T2 type; + }; + + // + // if_ + // + template + struct if_ + : public sprout::detail::if_c + {}; + } // namespace detail +} // namespace sprout + +#endif // #ifndef SPROUT_DETAIL_IF_HPP diff --git a/sprout/sprout/detail/iterator.hpp b/sprout/sprout/detail/iterator.hpp new file mode 100644 index 00000000..f7dbff16 --- /dev/null +++ b/sprout/sprout/detail/iterator.hpp @@ -0,0 +1,182 @@ +#ifndef SPROUT_DETAIL_ITERATOR_HPP +#define SPROUT_DETAIL_ITERATOR_HPP + +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace detail { + // + // distance + // + template + SPROUT_CONSTEXPR typename std::iterator_traits::difference_type distance( + Iterator first, + Iterator last + ) + { + return first == last ? 0 : 1 + sprout::detail::distance(first + 1, last); + } + + template + SPROUT_CONSTEXPR typename std::iterator_traits::difference_type bidirectional_distance_impl( + Iterator first1, + Iterator first2, + Iterator last, + typename std::iterator_traits::difference_type current = 1 + ) + { + return first1 == last + ? current + : first2 == last + ? -current + : sprout::detail::bidirectional_distance_impl(first1 + 1, first2 - 1, last, current + 1) + ; + } + // + // bidirectional_distance + // + template + SPROUT_CONSTEXPR typename std::iterator_traits::difference_type bidirectional_distance( + Iterator first, + Iterator last + ) + { + return first == last ? 0 : sprout::detail::bidirectional_distance_impl(first + 1, first - 1, last); + } + + // + // reverse_iterator + // + template + class reverse_iterator + : public std::iterator< + typename std::iterator_traits::iterator_category, + typename std::iterator_traits::value_type, + typename std::iterator_traits::difference_type, + typename std::iterator_traits::pointer, + typename std::iterator_traits::reference + > + { + public: + typedef Iterator iterator_type; + typedef typename std::iterator_traits::iterator_category iterator_category; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::difference_type difference_type; + typedef typename std::iterator_traits::pointer pointer; + typedef typename std::iterator_traits::reference reference; + protected: + iterator_type current; + private: + iterator_type deref_tmp; + public: + reverse_iterator() = default; + reverse_iterator(reverse_iterator const&) = default; + SPROUT_CONSTEXPR explicit reverse_iterator(iterator_type it) + : current(it) + , deref_tmp(current - 1) + {} + template + SPROUT_CONSTEXPR reverse_iterator(reverse_iterator const& it) + : current(it) + , deref_tmp(current - 1) + {} + template + reverse_iterator& operator=(const reverse_iterator& it) { + reverse_iterator temp(it); + temp.swap(this); + return this; + } + SPROUT_CONSTEXPR iterator_type base() const { + return current; + } + SPROUT_CONSTEXPR reference operator*() const { + return *deref_tmp; + } + SPROUT_CONSTEXPR pointer operator->() const { + return &*deref_tmp; + } + reverse_iterator& operator++() { + --current; + --deref_tmp; + return this; + } + reverse_iterator operator++(int) { + reverse_iterator result(this); + --current; + --deref_tmp; + return result; + } + reverse_iterator& operator--() { + ++current; + ++deref_tmp; + return this; + } + reverse_iterator operator--(int) { + reverse_iterator temp(this); + ++current; + ++deref_tmp; + return temp; + } + SPROUT_CONSTEXPR reverse_iterator operator+(difference_type n) const { + return reverse_iterator(current - n); + } + SPROUT_CONSTEXPR reverse_iterator operator-(difference_type n) const { + return reverse_iterator(current + n); + } + reverse_iterator& operator+=(difference_type n) { + reverse_iterator temp(current - n); + temp.swap(this); + return this; + } + reverse_iterator& operator-=(difference_type n) { + reverse_iterator temp(current + n); + temp.swap(this); + return this; + } + SPROUT_CONSTEXPR reference operator[](difference_type n) const { + return *(deref_tmp - n); + } + void swap(reverse_iterator& other) { + using std::swap; + swap(current, other.current); + swap(deref_tmp, other.deref_tmp); + } + }; + template + SPROUT_CONSTEXPR bool operator==( + sprout::detail::reverse_iterator const& lhs, + sprout::detail::reverse_iterator const& rhs + ) + { + return lhs.base() == rhs.base(); + } + template + SPROUT_CONSTEXPR bool operator!=( + sprout::detail::reverse_iterator const& lhs, + sprout::detail::reverse_iterator const& rhs + ) + { + return !(lhs == rhs); + } + template + SPROUT_CONSTEXPR sprout::detail::reverse_iterator operator+( + typename sprout::detail::reverse_iterator::difference_type n, + sprout::detail::reverse_iterator const& it + ) + { + return it + n; + } + + // + // swap + // + template + void swap(sprout::detail::reverse_iterator& lhs, sprout::detail::reverse_iterator& rhs) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) { + lhs.swap(rhs); + } + } // namespace detail +} // namespace sprout + +#endif // #ifndef SPROUT_DETAIL_ITERATOR_HPP diff --git a/sprout/sprout/detail/overlap_count.hpp b/sprout/sprout/detail/overlap_count.hpp new file mode 100644 index 00000000..485a5bc6 --- /dev/null +++ b/sprout/sprout/detail/overlap_count.hpp @@ -0,0 +1,72 @@ +#ifndef SPROUT_DETAIL_OVERLAP_COUNT_HPP +#define SPROUT_DETAIL_OVERLAP_COUNT_HPP + +#include +#include + +namespace sprout { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::iterator_traits::difference_type overlap_count_impl( + Iterator first, + Iterator last, + typename std::iterator_traits::value_type const& value, + typename std::iterator_traits::difference_type current = 0 + ) + { + return first == last + ? 0 + : *first == value + ? 1 + sprout::detail::overlap_count_impl(first + 1, last, value) + : sprout::detail::overlap_count_impl(first + 1, last, *first) + ; + } + // + // overlap_count + // + template + SPROUT_CONSTEXPR inline typename std::iterator_traits::difference_type overlap_count( + Iterator first, + Iterator last + ) + { + return first == last + ? 0 + : sprout::detail::overlap_count_impl(first + 1, last, *first) + ; + } + + template + SPROUT_CONSTEXPR inline typename std::iterator_traits::difference_type overlap_count_impl( + Iterator first, + Iterator last, + Predicate pred, + typename std::iterator_traits::value_type const& value + ) + { + return first == last + ? 0 + : pred(*first, value) + ? 1 + sprout::detail::overlap_count_impl(first + 1, last, pred, value) + : sprout::detail::overlap_count_impl(first + 1, last, pred, *first) + ; + } + // + // overlap_count + // + template + SPROUT_CONSTEXPR inline typename std::iterator_traits::difference_type overlap_count( + Iterator first, + Iterator last, + Predicate pred + ) + { + return first == last + ? 0 + : sprout::detail::overlap_count_impl(first + 1, last, pred, *first) + ; + } + } // namespace detail +} // namespace sprout + +#endif // #ifndef SPROUT_DETAIL_OVERLAP_COUNT_HPP diff --git a/sprout/sprout/detail/overlap_count_2.hpp b/sprout/sprout/detail/overlap_count_2.hpp new file mode 100644 index 00000000..0372bac3 --- /dev/null +++ b/sprout/sprout/detail/overlap_count_2.hpp @@ -0,0 +1,53 @@ +#ifndef SPROUT_DETAIL_OVERLAP_COUNT_2_HPP +#define SPROUT_DETAIL_OVERLAP_COUNT_2_HPP + +#include +#include + +namespace sprout { + namespace detail { + // + // overlap_count_2 + // + template + SPROUT_CONSTEXPR inline typename std::iterator_traits::difference_type overlap_count_2( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2, + Compare comp + ) + { + return first1 != last1 && first2 != last2 + ? comp(*first1, *first2) + ? sprout::detail::overlap_count_2(first1 + 1, last1, first2, last2, comp) + : comp(*first2, *first1) + ? sprout::detail::overlap_count_2(first1, last1, first2 + 1, last2, comp) + : 1 + sprout::detail::overlap_count_2(first1 + 1, last1, first2 + 1, last2, comp) + : 0 + ; + } + // + // overlap_count_2 + // + template + SPROUT_CONSTEXPR inline typename std::iterator_traits::difference_type overlap_count_2( + Iterator1 first1, + Iterator1 last1, + Iterator2 first2, + Iterator2 last2 + ) + { + return first1 != last1 && first2 != last2 + ? *first1 < *first2 + ? sprout::detail::overlap_count_2(first1 + 1, last1, first2, last2) + : *first2 < *first1 + ? sprout::detail::overlap_count_2(first1, last1, first2 + 1, last2) + : 1 + sprout::detail::overlap_count_2(first1 + 1, last1, first2 + 1, last2) + : 0 + ; + } + } // namespace detail +} // namespace sprout + +#endif // #ifndef SPROUT_DETAIL_OVERLAP_COUNT_2_HPP diff --git a/sprout/sprout/detail/param_at.hpp b/sprout/sprout/detail/param_at.hpp new file mode 100644 index 00000000..533884b8 --- /dev/null +++ b/sprout/sprout/detail/param_at.hpp @@ -0,0 +1,37 @@ +#ifndef SPROUT_DETAIL_PARAM_AT_HPP +#define SPROUT_DETAIL_PARAM_AT_HPP + +#include +#include +#include + +namespace sprout { + namespace detail { + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sizeof...(Values) == 0, + R + >::type param_at( + std::size_t n, + T const& v, + Values const&... values + ) + { + return v; + } + template + SPROUT_CONSTEXPR inline typename std::enable_if< + sizeof...(Values) != 0, + R + >::type param_at( + std::size_t n, + T const& v, + Values const&... values + ) + { + return n == 0 ? v : sprout::detail::param_at(n - 1, values...); + } + } // namespace detail +} // namespace sprout + +#endif // #ifndef SPROUT_DETAIL_PARAM_AT_HPP diff --git a/sprout/sprout/fixed_container.hpp b/sprout/sprout/fixed_container.hpp new file mode 100644 index 00000000..ae09bf53 --- /dev/null +++ b/sprout/sprout/fixed_container.hpp @@ -0,0 +1,9 @@ +#ifndef SPROUT_FIXED_CONTAINER_HPP +#define SPROUT_FIXED_CONTAINER_HPP + +#include +#include +#include +#include + +#endif // #ifndef SPROUT_FIXED_CONTAINER_HPP diff --git a/sprout/sprout/fixed_container/begin.hpp b/sprout/sprout/fixed_container/begin.hpp new file mode 100644 index 00000000..31300e26 --- /dev/null +++ b/sprout/sprout/fixed_container/begin.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_FIXED_CONTAINER_BEGIN_HPP +#define SPROUT_FIXED_CONTAINER_BEGIN_HPP + +#include +#include +#include + +namespace sprout { + // + // begin + // + template + typename sprout::fixed_container_traits::iterator begin(Range& range) { + return range.begin(); + } + template + typename sprout::fixed_container_traits::iterator begin(T (& arr)[N]) { + return arr; + } + // + // begin + // + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::const_iterator begin(Range const& range) { + return range.begin(); + } + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::const_iterator begin(T const (& arr)[N]) { + return arr; + } + + // + // cbegin + // + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::const_iterator cbegin(Range const& range) { + return range.begin(); + } + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::const_iterator cbegin(T const (& arr)[N]) { + return arr; + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_BEGIN_HPP diff --git a/sprout/sprout/fixed_container/clone.hpp b/sprout/sprout/fixed_container/clone.hpp new file mode 100644 index 00000000..fcc1980b --- /dev/null +++ b/sprout/sprout/fixed_container/clone.hpp @@ -0,0 +1,29 @@ +#ifndef SPROUT_FIXED_CONTAINER_CLONE_HPP +#define SPROUT_FIXED_CONTAINER_CLONE_HPP + +#include +#include + +namespace sprout { + // + // clone + // + template + inline typename sprout::fixed_container_traits::clone_type clone(Container& cont) { + return sprout::clone_functor().template operator()(cont); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits::clone_type clone(Container const& cont) { + return sprout::clone_functor().template operator()(cont); + } + + // + // cclone + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits::clone_type cclone(Container const& cont) { + return sprout::clone_functor().template operator()(cont); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_CLONE_HPP diff --git a/sprout/sprout/fixed_container/const_iterator.hpp b/sprout/sprout/fixed_container/const_iterator.hpp new file mode 100644 index 00000000..9cb646e7 --- /dev/null +++ b/sprout/sprout/fixed_container/const_iterator.hpp @@ -0,0 +1,18 @@ +#ifndef SPROUT_FIXED_CONTAINER_CONST_ITERATOR_HPP +#define SPROUT_FIXED_CONTAINER_CONST_ITERATOR_HPP + +#include +#include + +namespace sprout { + // + // fixed_const_iterator + // + template + struct fixed_const_iterator { + public: + typedef typename sprout::fixed_container_traits::const_iterator type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_CONST_ITERATOR_HPP diff --git a/sprout/sprout/fixed_container/const_pointer.hpp b/sprout/sprout/fixed_container/const_pointer.hpp new file mode 100644 index 00000000..6dba0e78 --- /dev/null +++ b/sprout/sprout/fixed_container/const_pointer.hpp @@ -0,0 +1,18 @@ +#ifndef SPROUT_FIXED_CONTAINER_CONST_POINTER_HPP +#define SPROUT_FIXED_CONTAINER_CONST_POINTER_HPP + +#include +#include + +namespace sprout { + // + // fixed_const_pointer + // + template + struct fixed_const_pointer { + public: + typedef typename sprout::fixed_container_traits::const_pointer type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_CONST_POINTER_HPP diff --git a/sprout/sprout/fixed_container/const_reference.hpp b/sprout/sprout/fixed_container/const_reference.hpp new file mode 100644 index 00000000..92023226 --- /dev/null +++ b/sprout/sprout/fixed_container/const_reference.hpp @@ -0,0 +1,18 @@ +#ifndef SPROUT_FIXED_CONTAINER_CONST_REFERENCE_HPP +#define SPROUT_FIXED_CONTAINER_CONST_REFERENCE_HPP + +#include +#include + +namespace sprout { + // + // fixed_const_reference + // + template + struct fixed_const_reference { + public: + typedef typename sprout::fixed_container_traits::const_reference type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_CONST_REFERENCE_HPP diff --git a/sprout/sprout/fixed_container/difference_type.hpp b/sprout/sprout/fixed_container/difference_type.hpp new file mode 100644 index 00000000..b0c6cba2 --- /dev/null +++ b/sprout/sprout/fixed_container/difference_type.hpp @@ -0,0 +1,18 @@ +#ifndef SPROUT_FIXED_CONTAINER_DIFFERENCE_TYPE_HPP +#define SPROUT_FIXED_CONTAINER_DIFFERENCE_TYPE_HPP + +#include +#include + +namespace sprout { + // + // fixed_difference_type + // + template + struct fixed_difference_type { + public: + typedef typename sprout::fixed_container_traits::difference_type type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_DIFFERENCE_TYPE_HPP diff --git a/sprout/sprout/fixed_container/empty.hpp b/sprout/sprout/fixed_container/empty.hpp new file mode 100644 index 00000000..d75f75eb --- /dev/null +++ b/sprout/sprout/fixed_container/empty.hpp @@ -0,0 +1,18 @@ +#ifndef SPROUT_FIXED_CONTAINER_EMPTY_HPP +#define SPROUT_FIXED_CONTAINER_EMPTY_HPP + +#include +#include +#include + +namespace sprout { + // + // empty + // + template + SPROUT_CONSTEXPR bool empty(Range const& range) { + return sprout::size(range) == 0; + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_EMPTY_HPP diff --git a/sprout/sprout/fixed_container/end.hpp b/sprout/sprout/fixed_container/end.hpp new file mode 100644 index 00000000..8df3a935 --- /dev/null +++ b/sprout/sprout/fixed_container/end.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_FIXED_CONTAINER_END_HPP +#define SPROUT_FIXED_CONTAINER_END_HPP + +#include +#include +#include + +namespace sprout { + // + // end + // + template + typename sprout::fixed_container_traits::iterator end(Range& range) { + return range.end(); + } + template + typename sprout::fixed_container_traits::iterator end(T (& arr)[N]) { + return arr + N; + } + // + // end + // + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::const_iterator end(Range const& range) { + return range.end(); + } + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::const_iterator end(T const (& arr)[N]) { + return arr + N; + } + + // + // cend + // + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::const_iterator cend(Range const& range) { + return range.end(); + } + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::const_iterator cend(T const (& arr)[N]) { + return arr + N; + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_END_HPP diff --git a/sprout/sprout/fixed_container/fixed_begin.hpp b/sprout/sprout/fixed_container/fixed_begin.hpp new file mode 100644 index 00000000..1a1c94b2 --- /dev/null +++ b/sprout/sprout/fixed_container/fixed_begin.hpp @@ -0,0 +1,37 @@ +#ifndef SPROUT_FIXED_CONTAINER_FIXED_BEGIN_HPP +#define SPROUT_FIXED_CONTAINER_FIXED_BEGIN_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // fixed_begin + // + template + typename sprout::fixed_container_traits< + typename sprout::fixed_container_traits::fixed_container_type + >::iterator fixed_begin(Range& range) { + return sprout::begin(sprout::get_fixed(range)); + } + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits< + typename sprout::fixed_container_traits::fixed_container_type + >::const_iterator fixed_begin(Range const& range) { + return sprout::begin(sprout::get_fixed(range)); + } + + // + // fixed_cbegin + // + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits< + typename sprout::fixed_container_traits::fixed_container_type + >::const_iterator fixed_cbegin(Range const& range) { + return sprout::begin(sprout::get_fixed(range)); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_FIXED_BEGIN_HPP diff --git a/sprout/sprout/fixed_container/fixed_begin_offset.hpp b/sprout/sprout/fixed_container/fixed_begin_offset.hpp new file mode 100644 index 00000000..e4cdb89c --- /dev/null +++ b/sprout/sprout/fixed_container/fixed_begin_offset.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_FIXED_CONTAINER_FIXED_BEGIN_OFFSET_HPP +#define SPROUT_FIXED_CONTAINER_FIXED_BEGIN_OFFSET_HPP + +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + // + // fixed_begin_offset + // + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::difference_type fixed_begin_offset(Range const& range) { + return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(range), sprout::begin(range)); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_FIXED_BEGIN_OFFSET_HPP diff --git a/sprout/sprout/fixed_container/fixed_container_type.hpp b/sprout/sprout/fixed_container/fixed_container_type.hpp new file mode 100644 index 00000000..f0509c51 --- /dev/null +++ b/sprout/sprout/fixed_container/fixed_container_type.hpp @@ -0,0 +1,18 @@ +#ifndef SPROUT_FIXED_CONTAINER_FIXED_CONTAINER_TYPE_HPP +#define SPROUT_FIXED_CONTAINER_FIXED_CONTAINER_TYPE_HPP + +#include +#include + +namespace sprout { + // + // fixed_container_type + // + template + struct fixed_container_type { + public: + typedef typename sprout::fixed_container_traits::fixed_container_type type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_FIXED_CONTAINER_TYPE_HPP diff --git a/sprout/sprout/fixed_container/fixed_end.hpp b/sprout/sprout/fixed_container/fixed_end.hpp new file mode 100644 index 00000000..901f6415 --- /dev/null +++ b/sprout/sprout/fixed_container/fixed_end.hpp @@ -0,0 +1,37 @@ +#ifndef SPROUT_FIXED_CONTAINER_FIXED_END_HPP +#define SPROUT_FIXED_CONTAINER_FIXED_END_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // fixed_end + // + template + typename sprout::fixed_container_traits< + typename sprout::fixed_container_traits::fixed_container_type + >::iterator fixed_end(Range& range) { + return sprout::end(sprout::get_fixed(range)); + } + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits< + typename sprout::fixed_container_traits::fixed_container_type + >::const_iterator fixed_end(Range const& range) { + return sprout::end(sprout::get_fixed(range)); + } + + // + // fixed_cend + // + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits< + typename sprout::fixed_container_traits::fixed_container_type + >::const_iterator fixed_cend(Range const& range) { + return sprout::end(sprout::get_fixed(range)); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_FIXED_END_HPP diff --git a/sprout/sprout/fixed_container/fixed_end_offset.hpp b/sprout/sprout/fixed_container/fixed_end_offset.hpp new file mode 100644 index 00000000..3d692311 --- /dev/null +++ b/sprout/sprout/fixed_container/fixed_end_offset.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_FIXED_CONTAINER_FIXED_END_OFFSET_HPP +#define SPROUT_FIXED_CONTAINER_FIXED_END_OFFSET_HPP + +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + // + // fixed_end_offset + // + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::difference_type fixed_end_offset(Range const& range) { + return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(range), sprout::end(range)); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_FIXED_END_OFFSET_HPP diff --git a/sprout/sprout/fixed_container/fixed_size.hpp b/sprout/sprout/fixed_container/fixed_size.hpp new file mode 100644 index 00000000..266960d3 --- /dev/null +++ b/sprout/sprout/fixed_container/fixed_size.hpp @@ -0,0 +1,22 @@ +#ifndef SPROUT_FIXED_CONTAINER_FIXED_SIZE_HPP +#define SPROUT_FIXED_CONTAINER_FIXED_SIZE_HPP + +#include +#include +#include + +namespace sprout { + // + // fixed_size + // + template + struct fixed_size { + public: + SPROUT_STATIC_CONSTEXPR typename sprout::fixed_container_traits::size_type value + = sprout::fixed_container_traits::fixed_size + ; + typedef std::integral_constant::size_type, value> type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_FIXED_SIZE_HPP diff --git a/sprout/sprout/fixed_container/functions.hpp b/sprout/sprout/fixed_container/functions.hpp new file mode 100644 index 00000000..40d4e42a --- /dev/null +++ b/sprout/sprout/fixed_container/functions.hpp @@ -0,0 +1,18 @@ +#ifndef SPROUT_FIXED_CONTAINER_FUNCTIONS_HPP +#define SPROUT_FIXED_CONTAINER_FUNCTIONS_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_FIXED_CONTAINER_FUNCTIONS_HPP diff --git a/sprout/sprout/fixed_container/get_fixed.hpp b/sprout/sprout/fixed_container/get_fixed.hpp new file mode 100644 index 00000000..21d6906b --- /dev/null +++ b/sprout/sprout/fixed_container/get_fixed.hpp @@ -0,0 +1,37 @@ +#ifndef SPROUT_FIXED_CONTAINER_GET_FIXED_HPP +#define SPROUT_FIXED_CONTAINER_GET_FIXED_HPP + +#include +#include + +namespace sprout { + // + // get_fixed + // + template + inline typename sprout::fixed_container_traits::fixed_container_type& get_fixed(Container& cont) { + return sprout::get_fixed_functor()(cont); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits::fixed_container_type const& get_fixed(Container const& cont) { + return sprout::get_fixed_functor()(cont); + } + + // + // get_cfixed + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits::fixed_container_type const& get_cfixed(Container const& cont) { + return sprout::get_fixed_functor()(cont); + } + + // + // get_fixed_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits::fixed_container_type get_fixed_copy(Container const& cont) { + return sprout::get_fixed_functor()(cont); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_GET_FIXED_HPP diff --git a/sprout/sprout/fixed_container/iterator.hpp b/sprout/sprout/fixed_container/iterator.hpp new file mode 100644 index 00000000..91ba76a5 --- /dev/null +++ b/sprout/sprout/fixed_container/iterator.hpp @@ -0,0 +1,24 @@ +#ifndef SPROUT_FIXED_CONTAINER_ITERATOR_HPP +#define SPROUT_FIXED_CONTAINER_ITERATOR_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // fixed_iterator + // + template + struct fixed_iterator { + public: + typedef typename sprout::detail::if_c< + std::is_const::value, + typename sprout::fixed_container_traits::const_iterator, + typename sprout::fixed_container_traits::iterator + >::type type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_ITERATOR_HPP diff --git a/sprout/sprout/fixed_container/make_clone.hpp b/sprout/sprout/fixed_container/make_clone.hpp new file mode 100644 index 00000000..1a4bd272 --- /dev/null +++ b/sprout/sprout/fixed_container/make_clone.hpp @@ -0,0 +1,17 @@ +#ifndef SPROUT_FIXED_CONTAINER_MAKE_CLONE_HPP +#define SPROUT_FIXED_CONTAINER_MAKE_CLONE_HPP + +#include +#include + +namespace sprout { + // + // make_clone + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits::clone_type make_clone(Args const&... args) { + return sprout::make_clone_functor().template operator()(args...); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_MAKE_CLONE_HPP diff --git a/sprout/sprout/fixed_container/metafunctions.hpp b/sprout/sprout/fixed_container/metafunctions.hpp new file mode 100644 index 00000000..881f5675 --- /dev/null +++ b/sprout/sprout/fixed_container/metafunctions.hpp @@ -0,0 +1,21 @@ +#ifndef SPROUT_FIXED_CONTAINER_METAFUNCTIONS_HPP +#define SPROUT_FIXED_CONTAINER_METAFUNCTIONS_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_FIXED_CONTAINER_METAFUNCTIONS_HPP diff --git a/sprout/sprout/fixed_container/mutable_iterator.hpp b/sprout/sprout/fixed_container/mutable_iterator.hpp new file mode 100644 index 00000000..dd3403c3 --- /dev/null +++ b/sprout/sprout/fixed_container/mutable_iterator.hpp @@ -0,0 +1,18 @@ +#ifndef SPROUT_FIXED_CONTAINER_MUTABLE_ITERATOR_HPP +#define SPROUT_FIXED_CONTAINER_MUTABLE_ITERATOR_HPP + +#include +#include + +namespace sprout { + // + // fixed_mutable_iterator + // + template + struct fixed_mutable_iterator { + public: + typedef typename sprout::fixed_container_traits::iterator type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_MUTABLE_ITERATOR_HPP diff --git a/sprout/sprout/fixed_container/mutable_pointer.hpp b/sprout/sprout/fixed_container/mutable_pointer.hpp new file mode 100644 index 00000000..00e9c317 --- /dev/null +++ b/sprout/sprout/fixed_container/mutable_pointer.hpp @@ -0,0 +1,18 @@ +#ifndef SPROUT_FIXED_CONTAINER_MUTABLE_POINTER_HPP +#define SPROUT_FIXED_CONTAINER_MUTABLE_POINTER_HPP + +#include +#include + +namespace sprout { + // + // fixed_mutable_pointer + // + template + struct fixed_mutable_pointer { + public: + typedef typename sprout::fixed_container_traits::pointer type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_MUTABLE_POINTER_HPP diff --git a/sprout/sprout/fixed_container/mutable_reference.hpp b/sprout/sprout/fixed_container/mutable_reference.hpp new file mode 100644 index 00000000..930ca604 --- /dev/null +++ b/sprout/sprout/fixed_container/mutable_reference.hpp @@ -0,0 +1,18 @@ +#ifndef SPROUT_FIXED_CONTAINER_MUTABLE_REFERENCE_HPP +#define SPROUT_FIXED_CONTAINER_MUTABLE_REFERENCE_HPP + +#include +#include + +namespace sprout { + // + // fixed_mutable_reference + // + template + struct fixed_mutable_reference { + public: + typedef typename sprout::fixed_container_traits::reference type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_MUTABLE_REFERENCE_HPP diff --git a/sprout/sprout/fixed_container/pointer.hpp b/sprout/sprout/fixed_container/pointer.hpp new file mode 100644 index 00000000..66c36fff --- /dev/null +++ b/sprout/sprout/fixed_container/pointer.hpp @@ -0,0 +1,24 @@ +#ifndef SPROUT_FIXED_CONTAINER_POINTER_HPP +#define SPROUT_FIXED_CONTAINER_POINTER_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // fixed_pointer + // + template + struct fixed_pointer { + public: + typedef typename sprout::detail::if_c< + std::is_const::value, + typename sprout::fixed_container_traits::const_pointer, + typename sprout::fixed_container_traits::pointer + >::type type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_POINTER_HPP diff --git a/sprout/sprout/fixed_container/rebind_fixed_size_eval.hpp b/sprout/sprout/fixed_container/rebind_fixed_size_eval.hpp new file mode 100644 index 00000000..ace9980f --- /dev/null +++ b/sprout/sprout/fixed_container/rebind_fixed_size_eval.hpp @@ -0,0 +1,17 @@ +#ifndef SPROUT_FIXED_CONTAINER_REBIND_FIXED_SIZE_EVAL_HPP +#define SPROUT_FIXED_CONTAINER_REBIND_FIXED_SIZE_EVAL_HPP + +#include +#include + +namespace sprout { + // + // rebind_fixed_size_eval + // + template::size_type S> + struct rebind_fixed_size_eval + : public rebind_fixed_size::template apply + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_REBIND_FIXED_SIZE_EVAL_HPP diff --git a/sprout/sprout/fixed_container/reference.hpp b/sprout/sprout/fixed_container/reference.hpp new file mode 100644 index 00000000..0a475755 --- /dev/null +++ b/sprout/sprout/fixed_container/reference.hpp @@ -0,0 +1,24 @@ +#ifndef SPROUT_FIXED_CONTAINER_REFERENCE_HPP +#define SPROUT_FIXED_CONTAINER_REFERENCE_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // fixed_reference + // + template + struct fixed_reference { + public: + typedef typename sprout::detail::if_c< + std::is_const::value, + typename sprout::fixed_container_traits::const_reference, + typename sprout::fixed_container_traits::reference + >::type type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_REFERENCE_HPP diff --git a/sprout/sprout/fixed_container/remake_clone.hpp b/sprout/sprout/fixed_container/remake_clone.hpp new file mode 100644 index 00000000..312851c7 --- /dev/null +++ b/sprout/sprout/fixed_container/remake_clone.hpp @@ -0,0 +1,39 @@ +#ifndef SPROUT_FIXED_CONTAINER_REMAKE_CLONE_HPP +#define SPROUT_FIXED_CONTAINER_REMAKE_CLONE_HPP + +#include +#include + +namespace sprout { + // + // remake_clone + // + template + inline typename sprout::fixed_container_traits::clone_type remake_clone( + Other& other, + typename sprout::fixed_container_traits::difference_type size, + Args const&... args + ) + { + return sprout::remake_clone_functor().template operator()(other, size, args...); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits::clone_type remake_clone(Other const& other, Args const&... args) { + return sprout::remake_clone_functor().template operator()(other, args...); + } + + // + // remake_cclone + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits::clone_type remake_cclone( + Other const& other, + typename sprout::fixed_container_traits::difference_type size, + Args const&... args + ) + { + return sprout::remake_clone_functor().template operator()(other, size, args...); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_REMAKE_CLONE_HPP diff --git a/sprout/sprout/fixed_container/size.hpp b/sprout/sprout/fixed_container/size.hpp new file mode 100644 index 00000000..24f86635 --- /dev/null +++ b/sprout/sprout/fixed_container/size.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_FIXED_CONTAINER_SIZE_HPP +#define SPROUT_FIXED_CONTAINER_SIZE_HPP + +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + // + // size + // + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::difference_type size(Range const& range) { + return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(range), sprout::end(range)); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_SIZE_HPP diff --git a/sprout/sprout/fixed_container/size_type.hpp b/sprout/sprout/fixed_container/size_type.hpp new file mode 100644 index 00000000..e8b1183e --- /dev/null +++ b/sprout/sprout/fixed_container/size_type.hpp @@ -0,0 +1,18 @@ +#ifndef SPROUT_FIXED_CONTAINER_SIZE_TYPE_HPP +#define SPROUT_FIXED_CONTAINER_SIZE_TYPE_HPP + +#include +#include + +namespace sprout { + // + // fixed_size_type + // + template + struct fixed_size_type { + public: + typedef typename sprout::fixed_container_traits::size_type type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_SIZE_TYPE_HPP diff --git a/sprout/sprout/fixed_container/traits.hpp b/sprout/sprout/fixed_container/traits.hpp new file mode 100644 index 00000000..3e1cce04 --- /dev/null +++ b/sprout/sprout/fixed_container/traits.hpp @@ -0,0 +1,153 @@ +#ifndef SPROUT_FIXED_CONTAINER_TRAITS_HPP +#define SPROUT_FIXED_CONTAINER_TRAITS_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace detail { + template + struct fixed_container_traits_base { + public: + typedef typename Container::value_type value_type; + typedef typename Container::iterator iterator; + typedef typename Container::const_iterator const_iterator; + typedef typename Container::reference reference; + typedef typename Container::const_reference const_reference; + typedef typename Container::size_type size_type; + typedef typename Container::difference_type difference_type; + typedef typename Container::pointer pointer; + typedef typename Container::const_pointer const_pointer; + }; + template + struct fixed_container_traits_base { + public: + typedef T value_type; + typedef T* iterator; + typedef T const* const_iterator; + typedef T& reference; + typedef T const& const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef T* pointer; + typedef T const* const_pointer; + }; + } // namespace detail + + // + // fixed_container_traits + // + template + struct fixed_container_traits + : public sprout::detail::fixed_container_traits_base + { + public: + typedef Container fixed_container_type; + typedef Container internal_type; + typedef Container clone_type; + public: + SPROUT_STATIC_CONSTEXPR typename sprout::detail::fixed_container_traits_base::size_type fixed_size + = std::tuple_size::type>::value + ; + }; + template + struct fixed_container_traits + : public sprout::detail::fixed_container_traits_base + { + public: + typedef T fixed_container_type[N]; + typedef T internal_type[N]; + typedef T clone_type[N]; + public: + SPROUT_STATIC_CONSTEXPR typename sprout::detail::fixed_container_traits_base::size_type fixed_size = N; + }; + + // + // rebind_fixed_size + // + template + struct rebind_fixed_size { + public: + template::size_type S> + struct apply; + }; + template + struct rebind_fixed_size { + public: + template::size_type S> + struct apply { + public: + typedef T type[S]; + }; + }; + + // + // get_fixed_functor + // + template + struct get_fixed_functor { + public: + typename sprout::fixed_container_traits::fixed_container_type& operator()(Container& cont) const { + return cont; + } + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::fixed_container_type const& operator()(Container const& cont) const { + return cont; + } + }; + + // + // clone_functor + // + template + struct clone_functor { + public: + typename sprout::fixed_container_traits::clone_type operator()(Container& cont) const { + return typename sprout::fixed_container_traits::clone_type(cont); + } + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::clone_type operator()(Container const& cont) const { + return typename sprout::fixed_container_traits::clone_type(cont); + } + }; + + // + // make_clone_functor + // + template + struct make_clone_functor { + public: + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::clone_type operator()(Args const&... args) const { + return typename sprout::fixed_container_traits::clone_type{args...}; + } + }; + + // + // remake_clone_functor + // + template + struct remake_clone_functor { + public: + template + typename sprout::fixed_container_traits::clone_type operator()( + Other& other, + typename sprout::fixed_container_traits::difference_type size, + Args const&... args + ) const + { + return sprout::make_clone_functor().template operator()(args...); + } + template + SPROUT_CONSTEXPR typename sprout::fixed_container_traits::clone_type operator()( + Other const& other, + typename sprout::fixed_container_traits::difference_type size, + Args const&... args + ) const + { + return sprout::make_clone_functor().template operator()(args...); + } + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_TRAITS_HPP diff --git a/sprout/sprout/fixed_container/value_type.hpp b/sprout/sprout/fixed_container/value_type.hpp new file mode 100644 index 00000000..ddb525e3 --- /dev/null +++ b/sprout/sprout/fixed_container/value_type.hpp @@ -0,0 +1,18 @@ +#ifndef SPROUT_FIXED_CONTAINER_VALUE_TYPE_HPP +#define SPROUT_FIXED_CONTAINER_VALUE_TYPE_HPP + +#include +#include + +namespace sprout { + // + // fixed_value_type + // + template + struct fixed_value_type { + public: + typedef typename sprout::fixed_container_traits::value_type type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_FIXED_CONTAINER_VALUE_TYPE_HPP diff --git a/sprout/sprout/index_tuple.hpp b/sprout/sprout/index_tuple.hpp new file mode 100644 index 00000000..4bab21dc --- /dev/null +++ b/sprout/sprout/index_tuple.hpp @@ -0,0 +1,59 @@ +#ifndef SPROUT_INDEX_TUPLE_HPP +#define SPROUT_INDEX_TUPLE_HPP + +#include +#include + +namespace sprout { + // + // index_tuple + // + template + struct index_tuple {}; + + // + // index_range + // + template< + std::ptrdiff_t First, + std::ptrdiff_t Last, + std::ptrdiff_t Step = 1, + typename Acc = sprout::index_tuple<>, + bool Break = (First >= Last) + > + struct index_range { + typedef Acc type; + }; + template< + std::ptrdiff_t First, + std::ptrdiff_t Last, + std::ptrdiff_t Step, + std::ptrdiff_t ...Indexes + > + struct index_range, false> + : public sprout::index_range > + {}; + + // + // index_n + // + template< + std::ptrdiff_t I, + std::ptrdiff_t N, + typename Acc = sprout::index_tuple<>, + bool Break = (N == 0) + > + struct index_n { + typedef Acc type; + }; + template< + std::ptrdiff_t I, + std::ptrdiff_t N, + std::ptrdiff_t ...Indexes + > + struct index_n, false> + : public sprout::index_n > + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_INDEX_TUPLE_HPP diff --git a/sprout/sprout/operation.hpp b/sprout/sprout/operation.hpp new file mode 100644 index 00000000..b99f98de --- /dev/null +++ b/sprout/sprout/operation.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_HPP +#define SPROUT_OPERATION_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_HPP diff --git a/sprout/sprout/operation/erase.hpp b/sprout/sprout/operation/erase.hpp new file mode 100644 index 00000000..173e920c --- /dev/null +++ b/sprout/sprout/operation/erase.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_ERASE_HPP +#define SPROUT_OPERATION_ERASE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_ERASE_HPP diff --git a/sprout/sprout/operation/erase_n.hpp b/sprout/sprout/operation/erase_n.hpp new file mode 100644 index 00000000..49d107cc --- /dev/null +++ b/sprout/sprout/operation/erase_n.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_ERASE_N_HPP +#define SPROUT_OPERATION_ERASE_N_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_ERASE_N_HPP diff --git a/sprout/sprout/operation/fit.hpp b/sprout/sprout/operation/fit.hpp new file mode 100644 index 00000000..19c3a572 --- /dev/null +++ b/sprout/sprout/operation/fit.hpp @@ -0,0 +1,25 @@ +#ifndef SPROUT_OPERATION_FIT_HPP +#define SPROUT_OPERATION_FIT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_FIT_HPP diff --git a/sprout/sprout/operation/fit/erase.hpp b/sprout/sprout/operation/fit/erase.hpp new file mode 100644 index 00000000..faa65401 --- /dev/null +++ b/sprout/sprout/operation/fit/erase.hpp @@ -0,0 +1,61 @@ +#ifndef SPROUT_OPERATION_FIT_ERASE_HPP +#define SPROUT_OPERATION_FIT_ERASE_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // erase + // + template + struct erase { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::erase::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // erase + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::erase::type erase( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::erase(cont, pos)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) - 1 + ); + } + // + // erase + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::erase::type erase( + Container const& cont, + typename sprout::fixed_container_traits::difference_type pos + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::erase(cont, pos)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) - 1 + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_ERASE_HPP diff --git a/sprout/sprout/operation/fit/erase_n.hpp b/sprout/sprout/operation/fit/erase_n.hpp new file mode 100644 index 00000000..85ee3c3e --- /dev/null +++ b/sprout/sprout/operation/fit/erase_n.hpp @@ -0,0 +1,61 @@ +#ifndef SPROUT_OPERATION_FIT_ERASE_N_HPP +#define SPROUT_OPERATION_FIT_ERASE_N_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // erase_n + // + template + struct erase_n { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::erase_n::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // erase_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::erase_n::type erase_n( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::erase_n(cont, pos)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) - 1 + ); + } + // + // erase_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::erase_n::type erase_n( + Container const& cont, + typename sprout::fixed_container_traits::difference_type pos + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::erase_n(cont, pos)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) - 1 + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_ERASE_N_HPP diff --git a/sprout/sprout/operation/fit/insert.hpp b/sprout/sprout/operation/fit/insert.hpp new file mode 100644 index 00000000..e6ee6d15 --- /dev/null +++ b/sprout/sprout/operation/fit/insert.hpp @@ -0,0 +1,65 @@ +#ifndef SPROUT_OPERATION_FIT_INSERT_HPP +#define SPROUT_OPERATION_FIT_INSERT_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // insert + // + template + struct insert { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::insert::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // insert + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::insert::type insert( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos, + T const& v, + Values const&... values + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::insert(cont, pos, v, values...)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) + 1 + sizeof...(Values) + ); + } + // + // insert + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::insert::type insert( + Container const& cont, + typename sprout::fixed_container_traits::difference_type pos, + T const& v, + Values const&... values + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::insert(cont, pos, v, values...)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) + 1 + sizeof...(Values) + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_INSERT_HPP diff --git a/sprout/sprout/operation/fit/insert_n.hpp b/sprout/sprout/operation/fit/insert_n.hpp new file mode 100644 index 00000000..9d05ce2f --- /dev/null +++ b/sprout/sprout/operation/fit/insert_n.hpp @@ -0,0 +1,65 @@ +#ifndef SPROUT_OPERATION_FIT_INSERT_N_HPP +#define SPROUT_OPERATION_FIT_INSERT_N_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // insert_n + // + template + struct insert_n { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::insert_n::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // insert_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::insert_n::type insert_n( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos, + T const& v, + Values const&... values + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::insert_n(cont, pos, v, values...)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) + (1 + sizeof...(Values)) * N + ); + } + // + // insert_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::insert_n::type insert_n( + Container const& cont, + typename sprout::fixed_container_traits::difference_type pos, + T const& v, + Values const&... values + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::insert_n(cont, pos, v, values...)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) + (1 + sizeof...(Values)) * N + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_INSERT_N_HPP diff --git a/sprout/sprout/operation/fit/join.hpp b/sprout/sprout/operation/fit/join.hpp new file mode 100644 index 00000000..2353563b --- /dev/null +++ b/sprout/sprout/operation/fit/join.hpp @@ -0,0 +1,62 @@ +#ifndef SPROUT_OPERATION_FIT_JOIN_HPP +#define SPROUT_OPERATION_FIT_JOIN_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // join + // + template + struct join { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::join::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // join + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::join::type join( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos, + Input const& input + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::join(cont, pos, input)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) + sprout::size(input) + ); + } + // + // join + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::join::type join( + Container const& cont, + typename sprout::fixed_container_traits::difference_type pos, + Input const& input + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::join(cont, pos, input)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) + sprout::size(input) + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_JOIN_HPP diff --git a/sprout/sprout/operation/fit/join_back.hpp b/sprout/sprout/operation/fit/join_back.hpp new file mode 100644 index 00000000..dc0c61c1 --- /dev/null +++ b/sprout/sprout/operation/fit/join_back.hpp @@ -0,0 +1,44 @@ +#ifndef SPROUT_OPERATION_FIT_JOIN_BACK_HPP +#define SPROUT_OPERATION_FIT_JOIN_BACK_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // join_back + // + template + struct join_back { + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::join_back::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // join_back + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::join_back::type join_back( + Container const& cont, + Input const& input + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::join_back(cont, input)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) + sprout::size(input) + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_JOIN_BACK_HPP diff --git a/sprout/sprout/operation/fit/join_front.hpp b/sprout/sprout/operation/fit/join_front.hpp new file mode 100644 index 00000000..f65a6293 --- /dev/null +++ b/sprout/sprout/operation/fit/join_front.hpp @@ -0,0 +1,44 @@ +#ifndef SPROUT_OPERATION_FIT_JOIN_FRONT_HPP +#define SPROUT_OPERATION_FIT_JOIN_FRONT_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // join_front + // + template + struct join_front { + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::join_front::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // join_front + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::join_front::type join_front( + Container const& cont, + Input const& input + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::join_front(cont, input)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) + sprout::size(input) + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_JOIN_FRONT_HPP diff --git a/sprout/sprout/operation/fit/pop_back.hpp b/sprout/sprout/operation/fit/pop_back.hpp new file mode 100644 index 00000000..22d5b348 --- /dev/null +++ b/sprout/sprout/operation/fit/pop_back.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_OPERATION_FIT_POP_BACK_HPP +#define SPROUT_OPERATION_FIT_POP_BACK_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // pop_back + // + template + struct pop_back { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::pop_back::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // pop_back + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::pop_back::type pop_back( + Container const& cont + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::pop_back(cont)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) - 1 + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_POP_BACK_HPP diff --git a/sprout/sprout/operation/fit/pop_back_n.hpp b/sprout/sprout/operation/fit/pop_back_n.hpp new file mode 100644 index 00000000..0621e834 --- /dev/null +++ b/sprout/sprout/operation/fit/pop_back_n.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_OPERATION_FIT_POP_BACK_N_HPP +#define SPROUT_OPERATION_FIT_POP_BACK_N_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // pop_back_n + // + template + struct pop_back_n { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::pop_back_n::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // pop_back_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::pop_back_n::type pop_back_n( + Container const& cont + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::pop_back_n(cont)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) - N + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_POP_BACK_N_HPP diff --git a/sprout/sprout/operation/fit/pop_front.hpp b/sprout/sprout/operation/fit/pop_front.hpp new file mode 100644 index 00000000..18c06701 --- /dev/null +++ b/sprout/sprout/operation/fit/pop_front.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_OPERATION_FIT_POP_FRONT_HPP +#define SPROUT_OPERATION_FIT_POP_FRONT_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // pop_front + // + template + struct pop_front { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::pop_front::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // pop_front + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::pop_front::type pop_front( + Container const& cont + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::pop_front(cont)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) - 1 + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_POP_FRONT_HPP diff --git a/sprout/sprout/operation/fit/pop_front_n.hpp b/sprout/sprout/operation/fit/pop_front_n.hpp new file mode 100644 index 00000000..d96670c6 --- /dev/null +++ b/sprout/sprout/operation/fit/pop_front_n.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_OPERATION_FIT_POP_FRONT_N_HPP +#define SPROUT_OPERATION_FIT_POP_FRONT_N_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // pop_front_n + // + template + struct pop_front_n { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::pop_front_n::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // pop_front_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::pop_front_n::type pop_front_n( + Container const& cont + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::pop_front_n(cont)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) - N + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_POP_FRONT_N_HPP diff --git a/sprout/sprout/operation/fit/push_back.hpp b/sprout/sprout/operation/fit/push_back.hpp new file mode 100644 index 00000000..3a653924 --- /dev/null +++ b/sprout/sprout/operation/fit/push_back.hpp @@ -0,0 +1,46 @@ +#ifndef SPROUT_OPERATION_FIT_PUSH_BACK_HPP +#define SPROUT_OPERATION_FIT_PUSH_BACK_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // push_back + // + template + struct push_back { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::push_back::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // push_back + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::push_back::type push_back( + Container const& cont, + T const& v, + Values const&... values + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::push_back(cont, v, values...)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) + 1 + sizeof...(Values) + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_PUSH_BACK_HPP diff --git a/sprout/sprout/operation/fit/push_back_n.hpp b/sprout/sprout/operation/fit/push_back_n.hpp new file mode 100644 index 00000000..85c9508b --- /dev/null +++ b/sprout/sprout/operation/fit/push_back_n.hpp @@ -0,0 +1,46 @@ +#ifndef SPROUT_OPERATION_FIT_PUSH_BACK_N_HPP +#define SPROUT_OPERATION_FIT_PUSH_BACK_N_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // push_back_n + // + template + struct push_back_n { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::push_back_n::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // push_back_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::push_back_n::type push_back_n( + Container const& cont, + T const& v, + Values const&... values + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::push_back_n(cont, v, values...)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) + (1 + sizeof...(Values)) * N + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_PUSH_BACK_N_HPP diff --git a/sprout/sprout/operation/fit/push_front.hpp b/sprout/sprout/operation/fit/push_front.hpp new file mode 100644 index 00000000..3cd0e178 --- /dev/null +++ b/sprout/sprout/operation/fit/push_front.hpp @@ -0,0 +1,46 @@ +#ifndef SPROUT_OPERATION_FIT_PUSH_FRONT_HPP +#define SPROUT_OPERATION_FIT_PUSH_FRONT_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // push_front + // + template + struct push_front { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::push_front::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // push_front + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::push_front::type push_front( + Container const& cont, + T const& v, + Values const&... values + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::push_front(cont, v, values...)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) + 1 + sizeof...(Values) + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_PUSH_FRONT_HPP diff --git a/sprout/sprout/operation/fit/push_front_n.hpp b/sprout/sprout/operation/fit/push_front_n.hpp new file mode 100644 index 00000000..3851b542 --- /dev/null +++ b/sprout/sprout/operation/fit/push_front_n.hpp @@ -0,0 +1,46 @@ +#ifndef SPROUT_OPERATION_FIT_PUSH_FRONT_N_HPP +#define SPROUT_OPERATION_FIT_PUSH_FRONT_N_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // push_front_n + // + template + struct push_front_n { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::push_front_n::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // push_front_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::push_front_n::type push_front_n( + Container const& cont, + T const& v, + Values const&... values + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::push_front_n(cont, v, values...)), + sprout::fixed_begin_offset(cont), + sprout::fixed_end_offset(cont) + (1 + sizeof...(Values)) * N + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_PUSH_FRONT_N_HPP diff --git a/sprout/sprout/operation/fit/realign.hpp b/sprout/sprout/operation/fit/realign.hpp new file mode 100644 index 00000000..041733cf --- /dev/null +++ b/sprout/sprout/operation/fit/realign.hpp @@ -0,0 +1,60 @@ +#ifndef SPROUT_OPERATION_FIT_REALIGN_HPP +#define SPROUT_OPERATION_FIT_REALIGN_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // realign + // + template + struct realign { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::realign::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // realign + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::realign::type realign( + Container const& cont, + T const& v + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::realign(cont, v)), + 0, + sprout::size(cont) + ); + } + + // + // realign + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::realign::type realign( + Container const& cont + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::realign(cont)), + 0, + sprout::size(cont) + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_REALIGN_HPP diff --git a/sprout/sprout/operation/fit/realign_to.hpp b/sprout/sprout/operation/fit/realign_to.hpp new file mode 100644 index 00000000..ee823357 --- /dev/null +++ b/sprout/sprout/operation/fit/realign_to.hpp @@ -0,0 +1,60 @@ +#ifndef SPROUT_OPERATION_FIT_REALIGN_TO_HPP +#define SPROUT_OPERATION_FIT_REALIGN_TO_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // realign_to + // + template + struct realign_to { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::realign_to::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // realign_to + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::realign_to::type realign_to( + Container const& cont, + T const& v + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::realign_to(cont, v)), + 0, + sprout::size(cont) + ); + } + + // + // realign_to + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::realign_to::type realign_to( + Container const& cont + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::realign_to(cont)), + 0, + sprout::size(cont) + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_REALIGN_TO_HPP diff --git a/sprout/sprout/operation/fit/resize.hpp b/sprout/sprout/operation/fit/resize.hpp new file mode 100644 index 00000000..ad2e2e8a --- /dev/null +++ b/sprout/sprout/operation/fit/resize.hpp @@ -0,0 +1,61 @@ +#ifndef SPROUT_OPERATION_FIT_RESIZE_HPP +#define SPROUT_OPERATION_FIT_RESIZE_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // resize + // + template + struct resize { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::resize::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // resize + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::resize::type resize( + Container const& cont, + T const& v + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::resize(cont, v)), + 0, + sprout::fixed_container_traits::type>::fixed_size + ); + } + + // + // resize + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::resize::type resize( + Container const& cont + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::resize(cont)), + 0, + sprout::fixed_container_traits::type>::fixed_size + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_RESIZE_HPP diff --git a/sprout/sprout/operation/fit/resize_backward.hpp b/sprout/sprout/operation/fit/resize_backward.hpp new file mode 100644 index 00000000..8c3d7452 --- /dev/null +++ b/sprout/sprout/operation/fit/resize_backward.hpp @@ -0,0 +1,61 @@ +#ifndef SPROUT_OPERATION_FIT_RESIZE_BACKWARD_HPP +#define SPROUT_OPERATION_FIT_RESIZE_BACKWARD_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace result_of { + // + // resize_backward + // + template + struct resize_backward { + public: + typedef sprout::sub_array< + typename sprout::fixed_container_traits< + typename sprout::fixed::result_of::resize_backward::type + >::internal_type + > type; + }; + } // namespace result_of + + // + // resize_backward + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::resize_backward::type resize_backward( + Container const& cont, + T const& v + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::resize_backward(cont, v)), + 0, + sprout::fixed_container_traits::type>::fixed_size + ); + } + + // + // resize_backward + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::resize_backward::type resize_backward( + Container const& cont + ) + { + return sprout::sub_copy( + sprout::get_fixed(sprout::fixed::resize_backward(cont)), + 0, + sprout::fixed_container_traits::type>::fixed_size + ); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIT_RESIZE_BACKWARD_HPP diff --git a/sprout/sprout/operation/fixed.hpp b/sprout/sprout/operation/fixed.hpp new file mode 100644 index 00000000..50104f45 --- /dev/null +++ b/sprout/sprout/operation/fixed.hpp @@ -0,0 +1,25 @@ +#ifndef SPROUT_OPERATION_FIXED_HPP +#define SPROUT_OPERATION_FIXED_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_FIXED_HPP diff --git a/sprout/sprout/operation/fixed/erase.hpp b/sprout/sprout/operation/fixed/erase.hpp new file mode 100644 index 00000000..74c49011 --- /dev/null +++ b/sprout/sprout/operation/fixed/erase.hpp @@ -0,0 +1,89 @@ +#ifndef SPROUT_OPERATION_FIXED_ERASE_HPP +#define SPROUT_OPERATION_FIXED_ERASE_HPP + +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace result_of { + // + // erase + // + template + struct erase { + static_assert(sprout::fixed_container_traits::fixed_size >= 1, "fixed_size >= 1"); + public: + typedef typename sprout::rebind_fixed_size< + Container + >::template apply< + sprout::fixed_container_traits::fixed_size - 1 + >::type type; + }; + } // namespace result_of + + namespace detail { + template + SPROUT_CONSTEXPR inline Result erase_impl( + Container const& cont, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type pos + ) + { + return sprout::remake_clone( + cont, + sprout::size(cont) - 1, + (Indexes < sprout::fixed_container_traits::fixed_size - 1 + ? (Indexes < pos + ? *(sprout::fixed_begin(cont) + Indexes) + : *(sprout::fixed_begin(cont) + Indexes + 1) + ) + : typename sprout::fixed_container_traits::value_type() + )... + ); + } + } // namespace detail + // + // erase + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::erase::type erase( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos + ) + { + return sprout::fixed::detail::erase_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), pos) + ); + } + // + // erase + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::erase::type erase( + Container const& cont, + typename sprout::fixed_container_traits::difference_type pos + ) + { + return sprout::fixed::detail::erase_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), 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 diff --git a/sprout/sprout/operation/fixed/erase_n.hpp b/sprout/sprout/operation/fixed/erase_n.hpp new file mode 100644 index 00000000..12d61e86 --- /dev/null +++ b/sprout/sprout/operation/fixed/erase_n.hpp @@ -0,0 +1,89 @@ +#ifndef SPROUT_OPERATION_FIXED_ERASE_N_HPP +#define SPROUT_OPERATION_FIXED_ERASE_N_HPP + +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace result_of { + // + // erase_n + // + template + struct erase_n { + static_assert(sprout::fixed_container_traits::fixed_size >= N, "fixed_size >= N"); + public: + typedef typename sprout::rebind_fixed_size< + Container + >::template apply< + sprout::fixed_container_traits::fixed_size - N + >::type type; + }; + } // namespace result_of + + namespace detail { + template + SPROUT_CONSTEXPR inline Result erase_n_impl( + Container const& cont, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type pos + ) + { + return sprout::remake_clone( + cont, + sprout::size(cont) - N, + (Indexes < sprout::fixed_container_traits::fixed_size - N + ? (Indexes < pos + ? *(sprout::fixed_begin(cont) + Indexes) + : *(sprout::fixed_begin(cont) + Indexes + N) + ) + : typename sprout::fixed_container_traits::value_type() + )... + ); + } + } // namespace detail + // + // erase_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::erase_n::type erase_n( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos + ) + { + return sprout::fixed::detail::erase_n_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), pos) + ); + } + // + // erase_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::erase_n::type erase_n( + Container const& cont, + typename sprout::fixed_container_traits::difference_type pos + ) + { + return sprout::fixed::detail::erase_n_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::begin(cont) + pos) + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::erase_n; + } // namespace result_of + + using sprout::fixed::erase_n; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_ERASE_N_HPP diff --git a/sprout/sprout/operation/fixed/insert.hpp b/sprout/sprout/operation/fixed/insert.hpp new file mode 100644 index 00000000..06774b81 --- /dev/null +++ b/sprout/sprout/operation/fixed/insert.hpp @@ -0,0 +1,102 @@ +#ifndef SPROUT_OPERATION_FIXED_INSERT_HPP +#define SPROUT_OPERATION_FIXED_INSERT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace result_of { + // + // insert + // + template + struct insert { + public: + typedef typename sprout::rebind_fixed_size< + Container + >::template apply< + sprout::fixed_container_traits::fixed_size + 1 + sizeof...(Values) + >::type type; + }; + } // namespace result_of + + namespace detail { + template + SPROUT_CONSTEXPR inline Result insert_impl( + Container const& cont, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type pos, + T const& v, + Values const&... values + ) + { + return sprout::remake_clone( + cont, + sprout::size(cont) + 1 + sizeof...(Values), + (Indexes < sprout::fixed_container_traits::fixed_size + 1 + sizeof...(Values) + ? (Indexes < pos + ? *(sprout::fixed_begin(cont) + Indexes) + : Indexes < pos + 1 + sizeof...(Values) + ? sprout::detail::param_at::value_type>(Indexes - pos, v, values...) + : *(sprout::fixed_begin(cont) + Indexes - (1 + sizeof...(Values))) + ) + : typename sprout::fixed_container_traits::value_type() + )... + ); + } + } // namespace detail + // + // insert + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::insert::type insert( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos, + T const& v, + Values const&... values + ) + { + return sprout::fixed::detail::insert_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), pos), + v, + values... + ); + } + // + // insert + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::insert::type insert( + Container const& cont, + typename sprout::fixed_container_traits::difference_type pos, + T const& v, + Values const&... values + ) + { + return sprout::fixed::detail::insert_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::begin(cont) + pos), + v, + values... + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::insert; + } // namespace result_of + + using sprout::fixed::insert; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_INSERT_HPP diff --git a/sprout/sprout/operation/fixed/insert_n.hpp b/sprout/sprout/operation/fixed/insert_n.hpp new file mode 100644 index 00000000..af6bdf28 --- /dev/null +++ b/sprout/sprout/operation/fixed/insert_n.hpp @@ -0,0 +1,103 @@ +#ifndef SPROUT_OPERATION_FIXED_INSERT_N_HPP +#define SPROUT_OPERATION_FIXED_INSERT_N_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace result_of { + // + // insert_n + // + template + struct insert_n { + public: + typedef typename sprout::rebind_fixed_size< + Container + >::template apply< + sprout::fixed_container_traits::fixed_size + (1 + sizeof...(Values)) * N + >::type type; + }; + } // namespace result_of + + namespace detail { + template + SPROUT_CONSTEXPR inline Result insert_n_impl( + Container const& cont, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type pos, + T const& v, + Values const&... values + ) + { + return sprout::remake_clone( + cont, + sprout::size(cont) + (1 + sizeof...(Values)) * N, + (Indexes < sprout::fixed_container_traits::fixed_size + (1 + sizeof...(Values)) * N + ? (Indexes < pos + ? *(sprout::fixed_begin(cont) + Indexes) + : Indexes < pos + (1 + sizeof...(Values)) * N + ? sprout::detail::param_at::value_type>((Indexes - pos) % (1 + sizeof...(Values)), v, values...) + : *(sprout::fixed_begin(cont) + Indexes - (1 + sizeof...(Values)) * N) + ) + : typename sprout::fixed_container_traits::value_type() + )... + ); + } + } // namespace detail + // + // insert_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::insert_n::type insert_n( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos, + T const& v, + Values const&... values + ) + { + return sprout::fixed::detail::insert_n_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), pos), + v, + values... + ); + } + // + // insert_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::insert_n::type insert_n( + Container const& cont, + typename sprout::fixed_container_traits::difference_type pos, + T const& v, + Values const&... values + ) + { + return sprout::fixed::detail::insert_n_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::begin(cont) + pos), + v, + values... + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::insert_n; + } // namespace result_of + + using sprout::fixed::insert_n; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_INSERT_N_HPP diff --git a/sprout/sprout/operation/fixed/join.hpp b/sprout/sprout/operation/fixed/join.hpp new file mode 100644 index 00000000..e6836bcc --- /dev/null +++ b/sprout/sprout/operation/fixed/join.hpp @@ -0,0 +1,98 @@ +#ifndef SPROUT_OPERATION_FIXED_JOIN_HPP +#define SPROUT_OPERATION_FIXED_JOIN_HPP + +#include +#include +#include +#include +#include +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace fixed { + namespace result_of { + // + // join + // + template + struct join { + public: + typedef typename sprout::rebind_fixed_size< + Container + >::template apply< + sprout::fixed_container_traits::fixed_size + sprout::fixed_container_traits::fixed_size + >::type type; + }; + } // namespace result_of + + namespace detail { + template + SPROUT_CONSTEXPR inline Result join_impl( + Container const& cont, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type pos, + typename sprout::fixed_container_traits::difference_type size, + Input const& input + ) + { + return sprout::remake_clone( + cont, + sprout::size(cont) + sprout::size(input), + (Indexes < sprout::fixed_container_traits::fixed_size + size + ? (Indexes < pos + ? *(sprout::fixed_begin(cont) + Indexes) + : Indexes < pos + size + ? *(sprout::begin(input) + Indexes - pos) + : *(sprout::fixed_begin(cont) + Indexes - size) + ) + : typename sprout::fixed_container_traits::value_type() + )... + ); + } + } // namespace detail + // + // join + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::join::type join( + Container const& cont, + typename sprout::fixed_container_traits::const_iterator pos, + Input const& input + ) + { + return sprout::fixed::detail::join_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), pos), + sprout::size(input), + input + ); + } + // + // join + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::join::type join( + Container const& cont, + typename sprout::fixed_container_traits::difference_type pos, + Input const& input + ) + { + return sprout::fixed::detail::join_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::begin(cont) + pos), + sprout::size(input), + input + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::join; + } // namespace result_of + + using sprout::fixed::join; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_JOIN_HPP diff --git a/sprout/sprout/operation/fixed/join_back.hpp b/sprout/sprout/operation/fixed/join_back.hpp new file mode 100644 index 00000000..a047bafb --- /dev/null +++ b/sprout/sprout/operation/fixed/join_back.hpp @@ -0,0 +1,49 @@ +#ifndef SPROUT_OPERATION_FIXED_JOIN_BACK_HPP +#define SPROUT_OPERATION_FIXED_JOIN_BACK_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // join_back + // + template + struct join_back + : public sprout::fixed::result_of::join + {}; + } // namespace result_of + + // + // join_back + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::join_back::type join_back( + Container const& cont, + Input const& input + ) + { + return sprout::fixed::detail::join_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::fixed_end_offset(cont), + sprout::size(input), + input + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::join_back; + } // namespace result_of + + using sprout::fixed::join_back; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_JOIN_BACK_HPP diff --git a/sprout/sprout/operation/fixed/join_front.hpp b/sprout/sprout/operation/fixed/join_front.hpp new file mode 100644 index 00000000..b09f8644 --- /dev/null +++ b/sprout/sprout/operation/fixed/join_front.hpp @@ -0,0 +1,49 @@ +#ifndef SPROUT_OPERATION_FIXED_JOIN_FRONT_HPP +#define SPROUT_OPERATION_FIXED_JOIN_FRONT_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // join_front + // + template + struct join_front + : public sprout::fixed::result_of::join + {}; + } // namespace result_of + + // + // join_front + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::join_front::type join_front( + Container const& cont, + Input const& input + ) + { + return sprout::fixed::detail::join_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::fixed_begin_offset(cont), + sprout::size(input), + input + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::join_front; + } // namespace result_of + + using sprout::fixed::join_front; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_JOIN_FRONT_HPP diff --git a/sprout/sprout/operation/fixed/pop_back.hpp b/sprout/sprout/operation/fixed/pop_back.hpp new file mode 100644 index 00000000..d662dc42 --- /dev/null +++ b/sprout/sprout/operation/fixed/pop_back.hpp @@ -0,0 +1,46 @@ +#ifndef SPROUT_OPERATION_FIXED_POP_BACK_HPP +#define SPROUT_OPERATION_FIXED_POP_BACK_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // pop_back + // + template + struct pop_back + : public sprout::fixed::result_of::erase + {}; + } // namespace result_of + + // + // pop_back + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::pop_back::type pop_back( + Container const& cont + ) + { + return sprout::fixed::detail::erase_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::fixed_end_offset(cont) - 1 + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::pop_back; + } // namespace result_of + + using sprout::fixed::pop_back; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_POP_BACK_HPP diff --git a/sprout/sprout/operation/fixed/pop_back_n.hpp b/sprout/sprout/operation/fixed/pop_back_n.hpp new file mode 100644 index 00000000..77e36380 --- /dev/null +++ b/sprout/sprout/operation/fixed/pop_back_n.hpp @@ -0,0 +1,46 @@ +#ifndef SPROUT_OPERATION_FIXED_POP_BACK_N_HPP +#define SPROUT_OPERATION_FIXED_POP_BACK_N_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // pop_back_n + // + template + struct pop_back_n + : public sprout::fixed::result_of::erase_n + {}; + } // namespace result_of + + // + // pop_back_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::pop_back_n::type pop_back_n( + Container const& cont + ) + { + return sprout::fixed::detail::erase_n_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::fixed_end_offset(cont) - N + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::pop_back_n; + } // namespace result_of + + using sprout::fixed::pop_back_n; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_POP_BACK_N_HPP diff --git a/sprout/sprout/operation/fixed/pop_front.hpp b/sprout/sprout/operation/fixed/pop_front.hpp new file mode 100644 index 00000000..054328a1 --- /dev/null +++ b/sprout/sprout/operation/fixed/pop_front.hpp @@ -0,0 +1,46 @@ +#ifndef SPROUT_OPERATION_FIXED_POP_FRONT_HPP +#define SPROUT_OPERATION_FIXED_POP_FRONT_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // pop_front + // + template + struct pop_front + : public sprout::fixed::result_of::erase + {}; + } // namespace result_of + + // + // pop_front + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::pop_front::type pop_front( + Container const& cont + ) + { + return sprout::fixed::detail::erase_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::fixed_begin_offset(cont) + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::pop_front; + } // namespace result_of + + using sprout::fixed::pop_front; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_POP_FRONT_HPP diff --git a/sprout/sprout/operation/fixed/pop_front_n.hpp b/sprout/sprout/operation/fixed/pop_front_n.hpp new file mode 100644 index 00000000..5469ee04 --- /dev/null +++ b/sprout/sprout/operation/fixed/pop_front_n.hpp @@ -0,0 +1,46 @@ +#ifndef SPROUT_OPERATION_FIXED_POP_FRONT_N_HPP +#define SPROUT_OPERATION_FIXED_POP_FRONT_N_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // pop_front_n + // + template + struct pop_front_n + : public sprout::fixed::result_of::erase_n + {}; + } // namespace result_of + + // + // pop_front_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::pop_front_n::type pop_front_n( + Container const& cont + ) + { + return sprout::fixed::detail::erase_n_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::fixed_begin_offset(cont) + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::pop_front_n; + } // namespace result_of + + using sprout::fixed::pop_front_n; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_POP_FRONT_N_HPP diff --git a/sprout/sprout/operation/fixed/push_back.hpp b/sprout/sprout/operation/fixed/push_back.hpp new file mode 100644 index 00000000..20bdc56d --- /dev/null +++ b/sprout/sprout/operation/fixed/push_back.hpp @@ -0,0 +1,50 @@ +#ifndef SPROUT_OPERATION_FIXED_PUSH_BACK_HPP +#define SPROUT_OPERATION_FIXED_PUSH_BACK_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // push_back + // + template + struct push_back + : public sprout::fixed::result_of::insert + {}; + } // namespace result_of + + // + // push_back + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::push_back::type push_back( + Container const& cont, + T const& v, + Values const&... values + ) + { + return sprout::fixed::detail::insert_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::fixed_end_offset(cont), + v, + values... + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::push_back; + } // namespace result_of + + using sprout::fixed::push_back; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_PUSH_BACK_HPP diff --git a/sprout/sprout/operation/fixed/push_back_n.hpp b/sprout/sprout/operation/fixed/push_back_n.hpp new file mode 100644 index 00000000..8aa16fc8 --- /dev/null +++ b/sprout/sprout/operation/fixed/push_back_n.hpp @@ -0,0 +1,50 @@ +#ifndef SPROUT_OPERATION_FIXED_PUSH_BACK_N_HPP +#define SPROUT_OPERATION_FIXED_PUSH_BACK_N_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // push_back_n + // + template + struct push_back_n + : public sprout::fixed::result_of::insert_n + {}; + } // namespace result_of + + // + // push_back_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::push_back_n::type push_back_n( + Container const& cont, + T const& v, + Values const&... values + ) + { + return sprout::fixed::detail::insert_n_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::fixed_end_offset(cont), + v, + values... + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::push_back_n; + } // namespace result_of + + using sprout::fixed::push_back_n; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_PUSH_BACK_N_HPP diff --git a/sprout/sprout/operation/fixed/push_front.hpp b/sprout/sprout/operation/fixed/push_front.hpp new file mode 100644 index 00000000..505ecce6 --- /dev/null +++ b/sprout/sprout/operation/fixed/push_front.hpp @@ -0,0 +1,50 @@ +#ifndef SPROUT_OPERATION_FIXED_PUSH_FRONT_HPP +#define SPROUT_OPERATION_FIXED_PUSH_FRONT_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // push_front + // + template + struct push_front + : public sprout::fixed::result_of::insert + {}; + } // namespace result_of + + // + // push_front + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::push_front::type push_front( + Container const& cont, + T const& v, + Values const&... values + ) + { + return sprout::fixed::detail::insert_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::fixed_begin_offset(cont), + v, + values... + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::push_front; + } // namespace result_of + + using sprout::fixed::push_front; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_PUSH_FRONT_HPP diff --git a/sprout/sprout/operation/fixed/push_front_n.hpp b/sprout/sprout/operation/fixed/push_front_n.hpp new file mode 100644 index 00000000..8c691f8d --- /dev/null +++ b/sprout/sprout/operation/fixed/push_front_n.hpp @@ -0,0 +1,50 @@ +#ifndef SPROUT_OPERATION_FIXED_PUSH_FRONT_N_HPP +#define SPROUT_OPERATION_FIXED_PUSH_FRONT_N_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // push_front_n + // + template + struct push_front_n + : public sprout::fixed::result_of::insert_n + {}; + } // namespace result_of + + // + // push_front_n + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::push_front_n::type push_front_n( + Container const& cont, + T const& v, + Values const&... values + ) + { + return sprout::fixed::detail::insert_n_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::fixed_begin_offset(cont), + v, + values... + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::push_front_n; + } // namespace result_of + + using sprout::fixed::push_front_n; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_PUSH_FRONT_N_HPP diff --git a/sprout/sprout/operation/fixed/realign.hpp b/sprout/sprout/operation/fixed/realign.hpp new file mode 100644 index 00000000..d5599f58 --- /dev/null +++ b/sprout/sprout/operation/fixed/realign.hpp @@ -0,0 +1,96 @@ +#ifndef SPROUT_OPERATION_FIXED_REALIGN_HPP +#define SPROUT_OPERATION_FIXED_REALIGN_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // realign + // + template + struct realign { + public: + typedef Container type; + }; + } // namespace result_of + + namespace detail { + template + SPROUT_CONSTEXPR inline Result realign_impl( + Container const& cont, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type size, + T const& v + ) + { + return sprout::make_clone( + (Indexes < size + ? *(sprout::begin(cont) + Indexes) + : v + )... + ); + } + } // namespace detail + // + // realign + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::realign::type realign( + Container const& cont, + T const& v + ) + { + return sprout::fixed::detail::realign_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::size(cont), + v + ); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline Result realign_impl( + Container const& cont, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type size + ) + { + return sprout::make_clone( + (Indexes < size + ? *(sprout::begin(cont) + Indexes) + : typename sprout::fixed_container_traits::value_type() + )... + ); + } + } // namespace detail + // + // realign + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::realign::type realign( + Container const& cont + ) + { + return sprout::fixed::detail::realign_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::size(cont) + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::realign; + } // namespace result_of + + using sprout::fixed::realign; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_REALIGN_HPP diff --git a/sprout/sprout/operation/fixed/realign_to.hpp b/sprout/sprout/operation/fixed/realign_to.hpp new file mode 100644 index 00000000..880389f9 --- /dev/null +++ b/sprout/sprout/operation/fixed/realign_to.hpp @@ -0,0 +1,68 @@ +#ifndef SPROUT_OPERATION_FIXED_REALIGN_TO_HPP +#define SPROUT_OPERATION_FIXED_REALIGN_TO_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // realign_to + // + template + struct realign_to { + public: + typedef typename sprout::rebind_fixed_size< + Result + >::template apply< + sprout::fixed_container_traits::fixed_size + >::type type; + }; + } // namespace result_of + + // + // realign_to + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::realign_to::type realign_to( + Container const& cont, + T const& v + ) + { + return sprout::fixed::detail::realign_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::size(cont), + v + ); + } + + // + // realign_to + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::realign_to::type realign_to( + Container const& cont + ) + { + return sprout::fixed::detail::realign_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::size(cont) + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::realign_to; + } // namespace result_of + + using sprout::fixed::realign_to; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_REALIGN_TO_HPP diff --git a/sprout/sprout/operation/fixed/resize.hpp b/sprout/sprout/operation/fixed/resize.hpp new file mode 100644 index 00000000..1663ae3a --- /dev/null +++ b/sprout/sprout/operation/fixed/resize.hpp @@ -0,0 +1,99 @@ +#ifndef SPROUT_OPERATION_FIXED_RESIZE_HPP +#define SPROUT_OPERATION_FIXED_RESIZE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // resize + // + template + struct resize { + public: + typedef typename sprout::rebind_fixed_size< + Container + >::template apply< + N + >::type type; + }; + } // namespace result_of + + namespace detail { + template + SPROUT_CONSTEXPR inline Result resize_impl( + Container const& cont, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type size, + T const& v + ) + { + return sprout::make_clone( + (Indexes < size + ? *(sprout::begin(cont) + Indexes) + : v + )... + ); + } + } // namespace detail + // + // resize + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::resize::type resize( + Container const& cont, + T const& v + ) + { + return sprout::fixed::detail::resize_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::size(cont), + v + ); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline Result resize_impl( + Container const& cont, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type size + ) + { + return sprout::make_clone( + (Indexes < size + ? *(sprout::begin(cont) + Indexes) + : typename sprout::fixed_container_traits::value_type() + )... + ); + } + } // namespace detail + // + // resize + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::resize::type resize( + Container const& cont + ) + { + return sprout::fixed::detail::resize_impl::type>( + cont, typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::size(cont) + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::resize; + } // namespace result_of + + using sprout::fixed::resize; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_RESIZE_HPP diff --git a/sprout/sprout/operation/fixed/resize_backward.hpp b/sprout/sprout/operation/fixed/resize_backward.hpp new file mode 100644 index 00000000..612229d8 --- /dev/null +++ b/sprout/sprout/operation/fixed/resize_backward.hpp @@ -0,0 +1,106 @@ +#ifndef SPROUT_OPERATION_FIXED_RESIZE_BACKWARD_HPP +#define SPROUT_OPERATION_FIXED_RESIZE_BACKWARD_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace result_of { + // + // resize_backward + // + template + struct resize_backward + : public sprout::fixed::result_of::resize + {}; + } // namespace result_of + + namespace detail { + template + SPROUT_CONSTEXPR inline Result resize_backward_impl( + Container const& cont, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type size, + typename sprout::fixed_container_traits::difference_type offset, + T const& v + ) + { + return sprout::make_clone( + (Indexes >= offset && Indexes < offset + size + ? *(sprout::begin(cont) + Indexes - offset) + : v + )... + ); + } + } // namespace detail + // + // resize_backward + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::resize_backward::type resize_backward( + Container const& cont, + T const& v + ) + { + return sprout::fixed::detail::resize_backward_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::size(cont), + static_cast::difference_type>( + sprout::fixed_container_traits::type>::fixed_size + ) + - sprout::size(cont), + v + ); + } + + namespace detail { + template + SPROUT_CONSTEXPR inline Result resize_backward_impl( + Container const& cont, + sprout::index_tuple, + typename sprout::fixed_container_traits::difference_type size, + typename sprout::fixed_container_traits::difference_type offset + ) + { + return sprout::make_clone( + (Indexes >= offset && Indexes < offset + size + ? *(sprout::begin(cont) + Indexes - offset) + : typename sprout::fixed_container_traits::value_type() + )... + ); + } + } // namespace detail + // + // resize_backward + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::resize_backward::type resize_backward( + Container const& cont + ) + { + return sprout::fixed::detail::resize_backward_impl::type>( + cont, + typename sprout::index_range<0, sprout::fixed_container_traits::type>::fixed_size>::type(), + sprout::size(cont), + static_cast::difference_type>( + sprout::fixed_container_traits::type>::fixed_size + ) + - sprout::size(cont) + ); + } + } // namespace fixed + + namespace result_of { + using sprout::fixed::result_of::resize_backward; + } // namespace result_of + + using sprout::fixed::resize_backward; +} // namespace sprout + +#endif // #ifndef SPROUT_OPERATION_FIXED_RESIZE_BACKWARD_HPP diff --git a/sprout/sprout/operation/insert.hpp b/sprout/sprout/operation/insert.hpp new file mode 100644 index 00000000..212251d1 --- /dev/null +++ b/sprout/sprout/operation/insert.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_INSERT_HPP +#define SPROUT_OPERATION_INSERT_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_INSERT_HPP diff --git a/sprout/sprout/operation/insert_n.hpp b/sprout/sprout/operation/insert_n.hpp new file mode 100644 index 00000000..5ee3ea99 --- /dev/null +++ b/sprout/sprout/operation/insert_n.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_INSERT_N_HPP +#define SPROUT_OPERATION_INSERT_N_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_INSERT_N_HPP diff --git a/sprout/sprout/operation/join.hpp b/sprout/sprout/operation/join.hpp new file mode 100644 index 00000000..9f3eef97 --- /dev/null +++ b/sprout/sprout/operation/join.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_JOIN_HPP +#define SPROUT_OPERATION_JOIN_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_JOIN_HPP diff --git a/sprout/sprout/operation/join_back.hpp b/sprout/sprout/operation/join_back.hpp new file mode 100644 index 00000000..40ea6dee --- /dev/null +++ b/sprout/sprout/operation/join_back.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_JOIN_BACK_HPP +#define SPROUT_OPERATION_JOIN_BACK_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_JOIN_BACK_HPP diff --git a/sprout/sprout/operation/join_front.hpp b/sprout/sprout/operation/join_front.hpp new file mode 100644 index 00000000..599f4b7f --- /dev/null +++ b/sprout/sprout/operation/join_front.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_JOIN_FRONT_HPP +#define SPROUT_OPERATION_JOIN_FRONT_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_JOIN_FRONT_HPP diff --git a/sprout/sprout/operation/pop_back.hpp b/sprout/sprout/operation/pop_back.hpp new file mode 100644 index 00000000..a4481bd1 --- /dev/null +++ b/sprout/sprout/operation/pop_back.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_POP_BACK_HPP +#define SPROUT_OPERATION_POP_BACK_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_POP_BACK_HPP diff --git a/sprout/sprout/operation/pop_back_n.hpp b/sprout/sprout/operation/pop_back_n.hpp new file mode 100644 index 00000000..a21627f3 --- /dev/null +++ b/sprout/sprout/operation/pop_back_n.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_POP_BACK_N_HPP +#define SPROUT_OPERATION_POP_BACK_N_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_POP_BACK_N_HPP diff --git a/sprout/sprout/operation/pop_front.hpp b/sprout/sprout/operation/pop_front.hpp new file mode 100644 index 00000000..b04307ec --- /dev/null +++ b/sprout/sprout/operation/pop_front.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_POP_FRONT_HPP +#define SPROUT_OPERATION_POP_FRONT_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_POP_FRONT_HPP diff --git a/sprout/sprout/operation/pop_front_n.hpp b/sprout/sprout/operation/pop_front_n.hpp new file mode 100644 index 00000000..1674d52f --- /dev/null +++ b/sprout/sprout/operation/pop_front_n.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_POP_FRONT_N_HPP +#define SPROUT_OPERATION_POP_FRONT_N_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_POP_FRONT_N_HPP diff --git a/sprout/sprout/operation/push_back.hpp b/sprout/sprout/operation/push_back.hpp new file mode 100644 index 00000000..fd6e3bbd --- /dev/null +++ b/sprout/sprout/operation/push_back.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_PUSH_BACK_HPP +#define SPROUT_OPERATION_PUSH_BACK_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_PUSH_BACK_HPP diff --git a/sprout/sprout/operation/push_back_n.hpp b/sprout/sprout/operation/push_back_n.hpp new file mode 100644 index 00000000..8f29d568 --- /dev/null +++ b/sprout/sprout/operation/push_back_n.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_PUSH_BACK_N_HPP +#define SPROUT_OPERATION_PUSH_BACK_N_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_PUSH_BACK_N_HPP diff --git a/sprout/sprout/operation/push_front.hpp b/sprout/sprout/operation/push_front.hpp new file mode 100644 index 00000000..d06a973b --- /dev/null +++ b/sprout/sprout/operation/push_front.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_PUSH_FRONT_HPP +#define SPROUT_OPERATION_PUSH_FRONT_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_PUSH_FRONT_HPP diff --git a/sprout/sprout/operation/push_front_n.hpp b/sprout/sprout/operation/push_front_n.hpp new file mode 100644 index 00000000..6e6021e7 --- /dev/null +++ b/sprout/sprout/operation/push_front_n.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_PUSH_FRONT_N_HPP +#define SPROUT_OPERATION_PUSH_FRONT_N_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_PUSH_FRONT_N_HPP diff --git a/sprout/sprout/operation/realign.hpp b/sprout/sprout/operation/realign.hpp new file mode 100644 index 00000000..138b6edc --- /dev/null +++ b/sprout/sprout/operation/realign.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_REALIGN_HPP +#define SPROUT_OPERATION_REALIGN_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_REALIGN_HPP diff --git a/sprout/sprout/operation/realign_to.hpp b/sprout/sprout/operation/realign_to.hpp new file mode 100644 index 00000000..f8d9bede --- /dev/null +++ b/sprout/sprout/operation/realign_to.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_REALIGN_TO_HPP +#define SPROUT_OPERATION_REALIGN_TO_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_REALIGN_TO_HPP diff --git a/sprout/sprout/operation/resize.hpp b/sprout/sprout/operation/resize.hpp new file mode 100644 index 00000000..2024c8ae --- /dev/null +++ b/sprout/sprout/operation/resize.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_RESIZE_HPP +#define SPROUT_OPERATION_RESIZE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_RESIZE_HPP diff --git a/sprout/sprout/operation/resize_backward.hpp b/sprout/sprout/operation/resize_backward.hpp new file mode 100644 index 00000000..5889e12d --- /dev/null +++ b/sprout/sprout/operation/resize_backward.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_OPERATION_RESIZE_BACKWARD_HPP +#define SPROUT_OPERATION_RESIZE_BACKWARD_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_OPERATION_RESIZE_BACKWARD_HPP diff --git a/sprout/sprout/range/algorithm.hpp b/sprout/sprout/range/algorithm.hpp new file mode 100644 index 00000000..27b7198c --- /dev/null +++ b/sprout/sprout/range/algorithm.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_HPP +#define SPROUT_RANGE_ALGORITHM_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_HPP diff --git a/sprout/sprout/range/algorithm/copy.hpp b/sprout/sprout/range/algorithm/copy.hpp new file mode 100644 index 00000000..1d86a148 --- /dev/null +++ b/sprout/sprout/range/algorithm/copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_COPY_HPP diff --git a/sprout/sprout/range/algorithm/copy_backward.hpp b/sprout/sprout/range/algorithm/copy_backward.hpp new file mode 100644 index 00000000..f6c1be2e --- /dev/null +++ b/sprout/sprout/range/algorithm/copy_backward.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_COPY_BACKWARD_HPP +#define SPROUT_RANGE_ALGORITHM_COPY_BACKWARD_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_COPY_BACKWARD_HPP diff --git a/sprout/sprout/range/algorithm/copy_if.hpp b/sprout/sprout/range/algorithm/copy_if.hpp new file mode 100644 index 00000000..97849df7 --- /dev/null +++ b/sprout/sprout/range/algorithm/copy_if.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_COPY_IF_HPP +#define SPROUT_RANGE_ALGORITHM_COPY_IF_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_COPY_IF_HPP diff --git a/sprout/sprout/range/algorithm/fit.hpp b/sprout/sprout/range/algorithm/fit.hpp new file mode 100644 index 00000000..c3d2bf05 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit.hpp @@ -0,0 +1,25 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_HPP diff --git a/sprout/sprout/range/algorithm/fit/copy.hpp b/sprout/sprout/range/algorithm/fit/copy.hpp new file mode 100644 index 00000000..1328ace8 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/copy.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type copy( + Input const& input, + Result const& result + ) + { + return sprout::fit::copy(sprout::begin(input), sprout::end(input), result); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fit/copy_backward.hpp b/sprout/sprout/range/algorithm/fit/copy_backward.hpp new file mode 100644 index 00000000..6e5bb24b --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/copy_backward.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_COPY_BACKWARD_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_COPY_BACKWARD_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // copy_backward + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type copy_backward( + Input const& input, + Result const& result + ) + { + return sprout::fit::copy_backward(sprout::begin(input), sprout::end(input), result); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_COPY_BACKWARD_HPP diff --git a/sprout/sprout/range/algorithm/fit/copy_if.hpp b/sprout/sprout/range/algorithm/fit/copy_if.hpp new file mode 100644 index 00000000..0a401502 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/copy_if.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_COPY_IF_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_COPY_IF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // copy_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type copy_if( + Input const& input, + Result const& result + ) + { + return sprout::fit::copy_if(sprout::begin(input), sprout::end(input), result); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_COPY_IF_HPP diff --git a/sprout/sprout/range/algorithm/fit/merge.hpp b/sprout/sprout/range/algorithm/fit/merge.hpp new file mode 100644 index 00000000..7d5c0663 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/merge.hpp @@ -0,0 +1,43 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_MERGE_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_MERGE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // merge + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type merge( + Input1 const& input1, + Input2 const& input2, + Result const& result, + Compare comp + ) + { + return sprout::fit::merge(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result, comp); + } + + // + // merge + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type merge( + Input1 const& input1, + Input2 const& input2, + Result const& result + ) + { + return sprout::fit::merge(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_MERGE_HPP diff --git a/sprout/sprout/range/algorithm/fit/partition_copy.hpp b/sprout/sprout/range/algorithm/fit/partition_copy.hpp new file mode 100644 index 00000000..276aa1f0 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/partition_copy.hpp @@ -0,0 +1,29 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_PARTITION_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_PARTITION_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // partition_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type partition_copy( + Input const& input, + Result const& result, + Predicate pred + ) + { + return sprout::fit::partition_copy(sprout::begin(input), sprout::end(input), result, pred); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_PARTITION_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fit/remove_copy.hpp b/sprout/sprout/range/algorithm/fit/remove_copy.hpp new file mode 100644 index 00000000..6b983e91 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/remove_copy.hpp @@ -0,0 +1,29 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_REMOVE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_REMOVE_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // remove_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type remove_copy( + Input const& input, + Result const& result, + T const& value + ) + { + return sprout::fit::remove_copy(sprout::begin(input), sprout::end(input), result, value); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_REMOVE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fit/remove_copy_if.hpp b/sprout/sprout/range/algorithm/fit/remove_copy_if.hpp new file mode 100644 index 00000000..ae3e9630 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/remove_copy_if.hpp @@ -0,0 +1,29 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_REMOVE_COPY_IF_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_REMOVE_COPY_IF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // remove_copy_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type remove_copy_if( + Input const& input, + Result const& result, + Predicate pred + ) + { + return sprout::fit::remove_copy_if(sprout::begin(input), sprout::end(input), result, pred); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_REMOVE_COPY_IF_HPP diff --git a/sprout/sprout/range/algorithm/fit/replace_copy.hpp b/sprout/sprout/range/algorithm/fit/replace_copy.hpp new file mode 100644 index 00000000..8f024bd8 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/replace_copy.hpp @@ -0,0 +1,30 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_REPLACE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_REPLACE_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // replace_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type replace_copy( + Input const& input, + Result const& result, + T const& old_value, + T const& new_value + ) + { + return sprout::fit::replace_copy(sprout::begin(input), sprout::end(input), result, old_value, new_value); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_REPLACE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fit/replace_copy_if.hpp b/sprout/sprout/range/algorithm/fit/replace_copy_if.hpp new file mode 100644 index 00000000..d7d0d3ee --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/replace_copy_if.hpp @@ -0,0 +1,30 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_REPLACE_COPY_IF_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_REPLACE_COPY_IF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // replace_copy_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type replace_copy_if( + Input const& input, + Result const& result, + Predicate pred, + T const& new_value + ) + { + return sprout::fit::replace_copy_if(sprout::begin(input), sprout::end(input), result, pred, new_value); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_REPLACE_COPY_IF_HPP diff --git a/sprout/sprout/range/algorithm/fit/reverse_copy.hpp b/sprout/sprout/range/algorithm/fit/reverse_copy.hpp new file mode 100644 index 00000000..d2c78ec2 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/reverse_copy.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_REVERSE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_REVERSE_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // reverse_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type reverse_copy( + Input const& input, + Result const& result + ) + { + return sprout::fit::reverse_copy(sprout::begin(input), sprout::end(input), result); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_REVERSE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fit/rotate_copy.hpp b/sprout/sprout/range/algorithm/fit/rotate_copy.hpp new file mode 100644 index 00000000..a7f4c6a0 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/rotate_copy.hpp @@ -0,0 +1,29 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_ROTATE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_ROTATE_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // rotate_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type rotate_copy( + Input const& input, + typename sprout::fixed_container_traits::const_iterator middle, + Result const& result + ) + { + return sprout::fit::rotate_copy(sprout::begin(input), middle, sprout::end(input), result); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_ROTATE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fit/set_difference.hpp b/sprout/sprout/range/algorithm/fit/set_difference.hpp new file mode 100644 index 00000000..86a4673f --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/set_difference.hpp @@ -0,0 +1,43 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_SET_DIFFERENCE_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_SET_DIFFERENCE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // set_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_difference( + Input1 const& input1, + Input2 const& input2, + Result const& result, + Compare comp + ) + { + return sprout::fit::set_difference(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result, comp); + } + + // + // set_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_difference( + Input1 const& input1, + Input2 const& input2, + Result const& result + ) + { + return sprout::fit::set_difference(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_SET_DIFFERENCE_HPP diff --git a/sprout/sprout/range/algorithm/fit/set_intersection.hpp b/sprout/sprout/range/algorithm/fit/set_intersection.hpp new file mode 100644 index 00000000..d93236cc --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/set_intersection.hpp @@ -0,0 +1,43 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_SET_INTERSECTION_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_SET_INTERSECTION_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // set_intersection + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_intersection( + Input1 const& input1, + Input2 const& input2, + Result const& result, + Compare comp + ) + { + return sprout::fit::set_intersection(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result, comp); + } + + // + // set_intersection + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_intersection( + Input1 const& input1, + Input2 const& input2, + Result const& result + ) + { + return sprout::fit::set_intersection(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_SET_INTERSECTION_HPP diff --git a/sprout/sprout/range/algorithm/fit/set_symmetric_difference.hpp b/sprout/sprout/range/algorithm/fit/set_symmetric_difference.hpp new file mode 100644 index 00000000..f3e8fc66 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/set_symmetric_difference.hpp @@ -0,0 +1,43 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_SET_SYMMETRIC_DIFFERENCE_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_SET_SYMMETRIC_DIFFERENCE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // set_symmetric_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_symmetric_difference( + Input1 const& input1, + Input2 const& input2, + Result const& result, + Compare comp + ) + { + return sprout::fit::set_symmetric_difference(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result, comp); + } + + // + // set_symmetric_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_symmetric_difference( + Input1 const& input1, + Input2 const& input2, + Result const& result + ) + { + return sprout::fit::set_symmetric_difference(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_SET_SYMMETRIC_DIFFERENCE_HPP diff --git a/sprout/sprout/range/algorithm/fit/set_union.hpp b/sprout/sprout/range/algorithm/fit/set_union.hpp new file mode 100644 index 00000000..76540cd5 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/set_union.hpp @@ -0,0 +1,43 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_SET_UNION_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_SET_UNION_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // set_union + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_union( + Input1 const& input1, + Input2 const& input2, + Result const& result, + Compare comp + ) + { + return sprout::fit::set_union(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result, comp); + } + + // + // set_union + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_union( + Input1 const& input1, + Input2 const& input2, + Result const& result + ) + { + return sprout::fit::set_union(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_SET_UNION_HPP diff --git a/sprout/sprout/range/algorithm/fit/stable_partition_copy.hpp b/sprout/sprout/range/algorithm/fit/stable_partition_copy.hpp new file mode 100644 index 00000000..fd7c0f6f --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/stable_partition_copy.hpp @@ -0,0 +1,29 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_STABLE_PARTITION_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_STABLE_PARTITION_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // stable_partition_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type stable_partition_copy( + Input const& input, + Result const& result, + Predicate pred + ) + { + return sprout::fit::stable_partition_copy(sprout::begin(input), sprout::end(input), result, pred); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_STABLE_PARTITION_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fit/swap_element_copy.hpp b/sprout/sprout/range/algorithm/fit/swap_element_copy.hpp new file mode 100644 index 00000000..478cb1bd --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/swap_element_copy.hpp @@ -0,0 +1,30 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_SWAP_ELEMENT_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_SWAP_ELEMENT_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // swap_element_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type swap_element_copy( + Input const& input, + Result const& result, + typename sprout::fixed_container_traits::const_iterator pos1, + typename sprout::fixed_container_traits::const_iterator pos2 + ) + { + return sprout::fit::swap_element_copy(sprout::begin(input), sprout::end(input), result, pos1, pos2); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_SWAP_ELEMENT_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fit/transform.hpp b/sprout/sprout/range/algorithm/fit/transform.hpp new file mode 100644 index 00000000..cb8e980c --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/transform.hpp @@ -0,0 +1,43 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_TRANSFORM_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_TRANSFORM_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // transform + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type transform( + Input const& input, + Result const& result, + UnaryOperation op + ) + { + return sprout::fit::transform(sprout::begin(input), sprout::end(input), result, op); + } + + // + // transform + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type transform( + Input1 const& input1, + Input2 const& input2, + Result const& result, + BinaryOperation op + ) + { + return sprout::fit::transform(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), result, op); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_TRANSFORM_HPP diff --git a/sprout/sprout/range/algorithm/fit/unique_copy.hpp b/sprout/sprout/range/algorithm/fit/unique_copy.hpp new file mode 100644 index 00000000..a76784b3 --- /dev/null +++ b/sprout/sprout/range/algorithm/fit/unique_copy.hpp @@ -0,0 +1,41 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIT_UNIQUE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIT_UNIQUE_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // unique_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type unique_copy( + Input const& input, + Result const& result + ) + { + return sprout::fit::unique_copy(sprout::begin(input), sprout::end(input), result); + } + + // + // unique_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm::type unique_copy( + Input const& input, + Result const& result, + BinaryPredicate pred + ) + { + return sprout::fit::unique_copy(sprout::begin(input), sprout::end(input), result, pred); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIT_UNIQUE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fixed.hpp b/sprout/sprout/range/algorithm/fixed.hpp new file mode 100644 index 00000000..0fc34326 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed.hpp @@ -0,0 +1,25 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_HPP diff --git a/sprout/sprout/range/algorithm/fixed/copy.hpp b/sprout/sprout/range/algorithm/fixed/copy.hpp new file mode 100644 index 00000000..005e54dc --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/copy.hpp @@ -0,0 +1,30 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type copy( + Input const& input, + Result const& result + ) + { + return sprout::fixed::copy(sprout::begin(input), sprout::end(input), result); + } + } // namespace fixed + + using sprout::range::fixed::copy; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fixed/copy_backward.hpp b/sprout/sprout/range/algorithm/fixed/copy_backward.hpp new file mode 100644 index 00000000..86bfa07e --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/copy_backward.hpp @@ -0,0 +1,30 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_COPY_BACKWARD_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_COPY_BACKWARD_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // copy_backward + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type copy_backward( + Input const& input, + Result const& result + ) + { + return sprout::fixed::copy_backward(sprout::begin(input), sprout::end(input), result); + } + } // namespace fixed + + using sprout::range::fixed::copy_backward; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_COPY_BACKWARD_HPP diff --git a/sprout/sprout/range/algorithm/fixed/copy_if.hpp b/sprout/sprout/range/algorithm/fixed/copy_if.hpp new file mode 100644 index 00000000..a0a9ece9 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/copy_if.hpp @@ -0,0 +1,30 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_COPY_IF_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_COPY_IF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // copy_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type copy_if( + Input const& input, + Result const& result + ) + { + return sprout::fixed::copy_if(sprout::begin(input), sprout::end(input), result); + } + } // namespace fixed + + using sprout::range::fixed::copy_if; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_COPY_IF_HPP diff --git a/sprout/sprout/range/algorithm/fixed/merge.hpp b/sprout/sprout/range/algorithm/fixed/merge.hpp new file mode 100644 index 00000000..517d57ce --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/merge.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_MERGE_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_MERGE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // merge + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type merge( + Input1 const& input1, + Input2 const& input2, + Result const& result, + Compare comp + ) + { + return sprout::fixed::merge(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result, comp); + } + + // + // merge + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type merge( + Input1 const& input1, + Input2 const& input2, + Result const& result + ) + { + return sprout::fixed::merge(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); + } + } // namespace fixed + + using sprout::range::fixed::merge; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_MERGE_HPP diff --git a/sprout/sprout/range/algorithm/fixed/partition_copy.hpp b/sprout/sprout/range/algorithm/fixed/partition_copy.hpp new file mode 100644 index 00000000..9a739113 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/partition_copy.hpp @@ -0,0 +1,31 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_PARTITION_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_PARTITION_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // partition_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type partition_copy( + Input const& input, + Result const& result, + Predicate pred + ) + { + return sprout::fixed::partition_copy(sprout::begin(input), sprout::end(input), result, pred); + } + } // namespace fixed + + using sprout::range::fixed::partition_copy; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_PARTITION_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fixed/remove_copy.hpp b/sprout/sprout/range/algorithm/fixed/remove_copy.hpp new file mode 100644 index 00000000..e46a3b38 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/remove_copy.hpp @@ -0,0 +1,31 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_REMOVE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_REMOVE_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // remove_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type remove_copy( + Input const& input, + Result const& result, + T const& value + ) + { + return sprout::fixed::remove_copy(sprout::begin(input), sprout::end(input), result, value); + } + } // namespace fixed + + using sprout::range::fixed::remove_copy; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_REMOVE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fixed/remove_copy_if.hpp b/sprout/sprout/range/algorithm/fixed/remove_copy_if.hpp new file mode 100644 index 00000000..e90cbb7c --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/remove_copy_if.hpp @@ -0,0 +1,31 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // remove_copy_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type remove_copy_if( + Input const& input, + Result const& result, + Predicate pred + ) + { + return sprout::fixed::remove_copy_if(sprout::begin(input), sprout::end(input), result, pred); + } + } // namespace fixed + + using sprout::range::fixed::remove_copy_if; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP diff --git a/sprout/sprout/range/algorithm/fixed/replace_copy.hpp b/sprout/sprout/range/algorithm/fixed/replace_copy.hpp new file mode 100644 index 00000000..d89584b0 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/replace_copy.hpp @@ -0,0 +1,32 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_REPLACE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_REPLACE_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // replace_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type replace_copy( + Input const& input, + Result const& result, + T const& old_value, + T const& new_value + ) + { + return sprout::fixed::replace_copy(sprout::begin(input), sprout::end(input), result, old_value, new_value); + } + } // namespace fixed + + using sprout::range::fixed::replace_copy; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_REPLACE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fixed/replace_copy_if.hpp b/sprout/sprout/range/algorithm/fixed/replace_copy_if.hpp new file mode 100644 index 00000000..8042561f --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/replace_copy_if.hpp @@ -0,0 +1,32 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_REPLACE_COPY_IF_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_REPLACE_COPY_IF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // replace_copy_if + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type replace_copy_if( + Input const& input, + Result const& result, + Predicate pred, + T const& new_value + ) + { + return sprout::fixed::replace_copy_if(sprout::begin(input), sprout::end(input), result, pred, new_value); + } + } // namespace fixed + + using sprout::range::fixed::replace_copy_if; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_REPLACE_COPY_IF_HPP diff --git a/sprout/sprout/range/algorithm/fixed/reverse_copy.hpp b/sprout/sprout/range/algorithm/fixed/reverse_copy.hpp new file mode 100644 index 00000000..7a712c6a --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/reverse_copy.hpp @@ -0,0 +1,30 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_REVERSE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_REVERSE_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // reverse_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type reverse_copy( + Input const& input, + Result const& result + ) + { + return sprout::fixed::reverse_copy(sprout::begin(input), sprout::end(input), result); + } + } // namespace fixed + + using sprout::range::fixed::reverse_copy; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_REVERSE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fixed/rotate_copy.hpp b/sprout/sprout/range/algorithm/fixed/rotate_copy.hpp new file mode 100644 index 00000000..97114067 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/rotate_copy.hpp @@ -0,0 +1,31 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_ROTATE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_ROTATE_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // rotate_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type rotate_copy( + Input const& input, + typename sprout::fixed_container_traits::const_iterator middle, + Result const& result + ) + { + return sprout::fixed::rotate_copy(sprout::begin(input), middle, sprout::end(input), result); + } + } // namespace fixed + + using sprout::range::fixed::rotate_copy; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_ROTATE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fixed/set_difference.hpp b/sprout/sprout/range/algorithm/fixed/set_difference.hpp new file mode 100644 index 00000000..99ecad48 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/set_difference.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_SET_DIFFERENCE_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_SET_DIFFERENCE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // set_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_difference( + Input1 const& input1, + Input2 const& input2, + Result const& result, + Compare comp + ) + { + return sprout::fixed::set_difference(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result, comp); + } + + // + // set_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_difference( + Input1 const& input1, + Input2 const& input2, + Result const& result + ) + { + return sprout::fixed::set_difference(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); + } + } // namespace fixed + + using sprout::range::fixed::set_difference; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_SET_DIFFERENCE_HPP diff --git a/sprout/sprout/range/algorithm/fixed/set_intersection.hpp b/sprout/sprout/range/algorithm/fixed/set_intersection.hpp new file mode 100644 index 00000000..ebb13940 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/set_intersection.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_SET_INTERSECTION_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_SET_INTERSECTION_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // set_intersection + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_intersection( + Input1 const& input1, + Input2 const& input2, + Result const& result, + Compare comp + ) + { + return sprout::fixed::set_intersection(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result, comp); + } + + // + // set_intersection + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_intersection( + Input1 const& input1, + Input2 const& input2, + Result const& result + ) + { + return sprout::fixed::set_intersection(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); + } + } // namespace fixed + + using sprout::range::fixed::set_intersection; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_SET_INTERSECTION_HPP diff --git a/sprout/sprout/range/algorithm/fixed/set_symmetric_difference.hpp b/sprout/sprout/range/algorithm/fixed/set_symmetric_difference.hpp new file mode 100644 index 00000000..be9f02d6 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/set_symmetric_difference.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_SET_SYMMETRIC_DIFFERENCE_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_SET_SYMMETRIC_DIFFERENCE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // set_symmetric_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_symmetric_difference( + Input1 const& input1, + Input2 const& input2, + Result const& result, + Compare comp + ) + { + return sprout::fixed::set_symmetric_difference(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result, comp); + } + + // + // set_symmetric_difference + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_symmetric_difference( + Input1 const& input1, + Input2 const& input2, + Result const& result + ) + { + return sprout::fixed::set_symmetric_difference(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); + } + } // namespace fixed + + using sprout::range::fixed::set_symmetric_difference; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_SET_SYMMETRIC_DIFFERENCE_HPP diff --git a/sprout/sprout/range/algorithm/fixed/set_union.hpp b/sprout/sprout/range/algorithm/fixed/set_union.hpp new file mode 100644 index 00000000..b80b1145 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/set_union.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_SET_UNION_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_SET_UNION_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // set_union + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_union( + Input1 const& input1, + Input2 const& input2, + Result const& result, + Compare comp + ) + { + return sprout::fixed::set_union(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result, comp); + } + + // + // set_union + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type set_union( + Input1 const& input1, + Input2 const& input2, + Result const& result + ) + { + return sprout::fixed::set_union(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), sprout::end(input2), result); + } + } // namespace fixed + + using sprout::range::fixed::set_union; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_SET_UNION_HPP diff --git a/sprout/sprout/range/algorithm/fixed/stable_partition_copy.hpp b/sprout/sprout/range/algorithm/fixed/stable_partition_copy.hpp new file mode 100644 index 00000000..79292756 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/stable_partition_copy.hpp @@ -0,0 +1,31 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_STABLE_PARTITION_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_STABLE_PARTITION_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // stable_partition_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type stable_partition_copy( + Input const& input, + Result const& result, + Predicate pred + ) + { + return sprout::fixed::stable_partition_copy(sprout::begin(input), sprout::end(input), result, pred); + } + } // namespace fixed + + using sprout::range::fixed::stable_partition_copy; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_STABLE_PARTITION_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fixed/swap_element_copy.hpp b/sprout/sprout/range/algorithm/fixed/swap_element_copy.hpp new file mode 100644 index 00000000..55d88558 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/swap_element_copy.hpp @@ -0,0 +1,32 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_SWAP_ELEMENT_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_SWAP_ELEMENT_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // swap_element_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type swap_element_copy( + Input const& input, + Result const& result, + typename sprout::fixed_container_traits::const_iterator pos1, + typename sprout::fixed_container_traits::const_iterator pos2 + ) + { + return sprout::fixed::swap_element_copy(sprout::begin(input), sprout::end(input), result, pos1, pos2); + } + } // namespace fixed + + using sprout::range::fixed::swap_element_copy; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_SWAP_ELEMENT_COPY_HPP diff --git a/sprout/sprout/range/algorithm/fixed/transform.hpp b/sprout/sprout/range/algorithm/fixed/transform.hpp new file mode 100644 index 00000000..53b76885 --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/transform.hpp @@ -0,0 +1,45 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_TRANSFORM_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_TRANSFORM_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // transform + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type transform( + Input const& input, + Result const& result, + UnaryOperation op + ) + { + return sprout::fixed::transform(sprout::begin(input), sprout::end(input), result, op); + } + + // + // transform + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type transform( + Input1 const& input1, + Input2 const& input2, + Result const& result, + BinaryOperation op + ) + { + return sprout::fixed::transform(sprout::begin(input1), sprout::end(input1), sprout::begin(input2), result, op); + } + } // namespace fixed + + using sprout::range::fixed::transform; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_TRANSFORM_HPP diff --git a/sprout/sprout/range/algorithm/fixed/unique_copy.hpp b/sprout/sprout/range/algorithm/fixed/unique_copy.hpp new file mode 100644 index 00000000..51f6accd --- /dev/null +++ b/sprout/sprout/range/algorithm/fixed/unique_copy.hpp @@ -0,0 +1,43 @@ +#ifndef SPROUT_RANGE_ALGORITHM_FIXED_UNIQUE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_FIXED_UNIQUE_COPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // unique_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type unique_copy( + Input const& input, + Result const& result + ) + { + return sprout::fixed::unique_copy(sprout::begin(input), sprout::end(input), result); + } + + // + // unique_copy + // + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type unique_copy( + Input const& input, + Result const& result, + BinaryPredicate pred + ) + { + return sprout::fixed::unique_copy(sprout::begin(input), sprout::end(input), result, pred); + } + } // namespace fixed + + using sprout::range::fixed::unique_copy; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIXED_UNIQUE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/merge.hpp b/sprout/sprout/range/algorithm/merge.hpp new file mode 100644 index 00000000..0a1a7d83 --- /dev/null +++ b/sprout/sprout/range/algorithm/merge.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_MERGE_HPP +#define SPROUT_RANGE_ALGORITHM_MERGE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_MERGE_HPP diff --git a/sprout/sprout/range/algorithm/partition_copy.hpp b/sprout/sprout/range/algorithm/partition_copy.hpp new file mode 100644 index 00000000..30ca104e --- /dev/null +++ b/sprout/sprout/range/algorithm/partition_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_PARTITION_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_PARTITION_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_PARTITION_COPY_HPP diff --git a/sprout/sprout/range/algorithm/remove_copy.hpp b/sprout/sprout/range/algorithm/remove_copy.hpp new file mode 100644 index 00000000..0aa3b172 --- /dev/null +++ b/sprout/sprout/range/algorithm/remove_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_REMOVE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_REMOVE_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_REMOVE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/remove_copy_if.hpp b/sprout/sprout/range/algorithm/remove_copy_if.hpp new file mode 100644 index 00000000..7cb45ec4 --- /dev/null +++ b/sprout/sprout/range/algorithm/remove_copy_if.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_REMOVE_COPY_IF_HPP +#define SPROUT_RANGE_ALGORITHM_REMOVE_COPY_IF_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_REMOVE_COPY_IF_HPP diff --git a/sprout/sprout/range/algorithm/replace_copy.hpp b/sprout/sprout/range/algorithm/replace_copy.hpp new file mode 100644 index 00000000..da4aa650 --- /dev/null +++ b/sprout/sprout/range/algorithm/replace_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_REPLACE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_REPLACE_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_REPLACE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/replace_copy_if.hpp b/sprout/sprout/range/algorithm/replace_copy_if.hpp new file mode 100644 index 00000000..2aa505f7 --- /dev/null +++ b/sprout/sprout/range/algorithm/replace_copy_if.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_REPLACE_COPY_IF_HPP +#define SPROUT_RANGE_ALGORITHM_REPLACE_COPY_IF_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_REPLACE_COPY_IF_HPP diff --git a/sprout/sprout/range/algorithm/reverse_copy.hpp b/sprout/sprout/range/algorithm/reverse_copy.hpp new file mode 100644 index 00000000..68b0bdff --- /dev/null +++ b/sprout/sprout/range/algorithm/reverse_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_REVERSE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_REVERSE_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_REVERSE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/rotate_copy.hpp b/sprout/sprout/range/algorithm/rotate_copy.hpp new file mode 100644 index 00000000..f644b779 --- /dev/null +++ b/sprout/sprout/range/algorithm/rotate_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_ROTATE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_ROTATE_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_ROTATE_COPY_HPP diff --git a/sprout/sprout/range/algorithm/set_difference.hpp b/sprout/sprout/range/algorithm/set_difference.hpp new file mode 100644 index 00000000..d3b95d70 --- /dev/null +++ b/sprout/sprout/range/algorithm/set_difference.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_SET_DIFFERENCE_HPP +#define SPROUT_RANGE_ALGORITHM_SET_DIFFERENCE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_SET_DIFFERENCE_HPP diff --git a/sprout/sprout/range/algorithm/set_intersection.hpp b/sprout/sprout/range/algorithm/set_intersection.hpp new file mode 100644 index 00000000..08123c48 --- /dev/null +++ b/sprout/sprout/range/algorithm/set_intersection.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_SET_INTERSECTION_HPP +#define SPROUT_RANGE_ALGORITHM_SET_INTERSECTION_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_SET_INTERSECTION_HPP diff --git a/sprout/sprout/range/algorithm/set_symmetric_difference.hpp b/sprout/sprout/range/algorithm/set_symmetric_difference.hpp new file mode 100644 index 00000000..a3272813 --- /dev/null +++ b/sprout/sprout/range/algorithm/set_symmetric_difference.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_SET_SYMMETRIC_DIFFERENCE_HPP +#define SPROUT_RANGE_ALGORITHM_SET_SYMMETRIC_DIFFERENCE_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_SET_SYMMETRIC_DIFFERENCE_HPP diff --git a/sprout/sprout/range/algorithm/set_union.hpp b/sprout/sprout/range/algorithm/set_union.hpp new file mode 100644 index 00000000..0159ec56 --- /dev/null +++ b/sprout/sprout/range/algorithm/set_union.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_SET_UNION_HPP +#define SPROUT_RANGE_ALGORITHM_SET_UNION_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_SET_UNION_HPP diff --git a/sprout/sprout/range/algorithm/stable_partition_copy.hpp b/sprout/sprout/range/algorithm/stable_partition_copy.hpp new file mode 100644 index 00000000..c8d7f744 --- /dev/null +++ b/sprout/sprout/range/algorithm/stable_partition_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_STABLE_PARTITION_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_STABLE_PARTITION_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_STABLE_PARTITION_COPY_HPP diff --git a/sprout/sprout/range/algorithm/swap_element_copy.hpp b/sprout/sprout/range/algorithm/swap_element_copy.hpp new file mode 100644 index 00000000..524c69c5 --- /dev/null +++ b/sprout/sprout/range/algorithm/swap_element_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_SWAP_ELEMENT_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_SWAP_ELEMENT_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_SWAP_ELEMENT_COPY_HPP diff --git a/sprout/sprout/range/algorithm/transform.hpp b/sprout/sprout/range/algorithm/transform.hpp new file mode 100644 index 00000000..c0880890 --- /dev/null +++ b/sprout/sprout/range/algorithm/transform.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_TRANSFORM_HPP +#define SPROUT_RANGE_ALGORITHM_TRANSFORM_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_TRANSFORM_HPP diff --git a/sprout/sprout/range/algorithm/unique_copy.hpp b/sprout/sprout/range/algorithm/unique_copy.hpp new file mode 100644 index 00000000..a6d0b16a --- /dev/null +++ b/sprout/sprout/range/algorithm/unique_copy.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_RANGE_ALGORITHM_UNIQUE_COPY_HPP +#define SPROUT_RANGE_ALGORITHM_UNIQUE_COPY_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_ALGORITHM_UNIQUE_COPY_HPP diff --git a/sprout/sprout/string.hpp b/sprout/sprout/string.hpp new file mode 100644 index 00000000..2203f73a --- /dev/null +++ b/sprout/sprout/string.hpp @@ -0,0 +1,520 @@ +#ifndef SPROUT_STRING_HPP +#define SPROUT_STRING_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + // + // basic_string + // + template + class basic_string { + public: + typedef T value_type; + typedef T* iterator; + typedef T const* const_iterator; + typedef T& reference; + typedef T const& const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef T* pointer; + typedef T const* const_pointer; + typedef sprout::detail::reverse_iterator reverse_iterator; + typedef sprout::detail::reverse_iterator const_reverse_iterator; + public: + SPROUT_STATIC_CONSTEXPR size_type static_size = N; + SPROUT_STATIC_CONSTEXPR size_type fixed_size = static_size; + public: + T elems[N + 1]; + public: + SPROUT_CONSTEXPR size_type size() const SPROUT_NOEXCEPT { + return N; + } + SPROUT_CONSTEXPR bool empty() const SPROUT_NOEXCEPT { + return N != 0; + } + SPROUT_CONSTEXPR size_type max_size() const SPROUT_NOEXCEPT { + return size(); + } + void rangecheck(size_type i) const { + if (i >= size()) { + throw std::out_of_range("basic_string<>: index out of range"); + } + } + iterator begin() SPROUT_NOEXCEPT { + return elems; + } + SPROUT_CONSTEXPR const_iterator begin() const SPROUT_NOEXCEPT { + return elems; + } + SPROUT_CONSTEXPR const_iterator cbegin() const SPROUT_NOEXCEPT { + return elems; + } + iterator end() SPROUT_NOEXCEPT { + return elems + size(); + } + SPROUT_CONSTEXPR const_iterator end() const SPROUT_NOEXCEPT { + return elems + size(); + } + SPROUT_CONSTEXPR const_iterator cend() const SPROUT_NOEXCEPT { + return elems + size(); + } + reverse_iterator rbegin() SPROUT_NOEXCEPT { + return reverse_iterator(begin()); + } + SPROUT_CONSTEXPR const_reverse_iterator rbegin() const SPROUT_NOEXCEPT { + return const_reverse_iterator(begin()); + } + SPROUT_CONSTEXPR const_reverse_iterator crbegin() const SPROUT_NOEXCEPT { + return const_reverse_iterator(begin()); + } + reverse_iterator rend() SPROUT_NOEXCEPT { + return reverse_iterator(end()); + } + SPROUT_CONSTEXPR const_reverse_iterator rend() const SPROUT_NOEXCEPT { + return const_reverse_iterator(end()); + } + SPROUT_CONSTEXPR const_reverse_iterator crend() const SPROUT_NOEXCEPT { + return const_reverse_iterator(end()); + } + reference operator[](size_type i) { + return elems[i]; + } + SPROUT_CONSTEXPR const_reference operator[](size_type i) const { + return elems[i]; + } + reference at(size_type i) { + rangecheck(i); + return elems[i]; + } + const_reference at(size_type i) const { + rangecheck(i); + return elems[i]; + } + reference front() { + return elems[0]; + } + SPROUT_CONSTEXPR const_reference front() const { + return elems[0]; + } + reference back() { + return elems[size() - 1]; + } + SPROUT_CONSTEXPR const_reference back() const { + return elems[size() - 1]; + } + pointer data() SPROUT_NOEXCEPT { + return elems; + } + SPROUT_CONSTEXPR const_pointer data() const SPROUT_NOEXCEPT { + return elems; + } + pointer c_array() SPROUT_NOEXCEPT { + return elems; + } + const_pointer c_str() const SPROUT_NOEXCEPT { + return elems; + } + void assign(const_reference value) { + fill(value); + } + void fill(const_reference value) { + std::fill_n(begin(), size(), value); + } + void swap(basic_string& other) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::swap(std::declval(), std::declval()))) { + std::swap_ranges(other.begin(), other.end(), begin()); + } + template + basic_string& operator=(basic_string const& rhs) { + std::copy(rhs.begin(), rhs.end(), begin()); + return *this; + } + template + basic_string& operator=(basic_string&& rhs) { + std::move(rhs.begin(), rhs.end(), begin()); + return *this; + } + }; + template + SPROUT_CONSTEXPR inline bool operator==(sprout::basic_string const& lhs, sprout::basic_string const& rhs) { + return N1 == N2 && NS_SSCRISK_CEL_OR_SPROUT_DETAIL::equal(lhs.begin(), lhs.end(), rhs.begin()); + } + template + SPROUT_CONSTEXPR inline bool operator!=(sprout::basic_string const& lhs, sprout::basic_string const& rhs) { + return !(lhs == rhs); + } + template + SPROUT_CONSTEXPR inline bool operator<(sprout::basic_string const& lhs, sprout::basic_string const& rhs) { + return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + } + template + SPROUT_CONSTEXPR inline bool operator>(sprout::basic_string const& lhs, sprout::basic_string const& rhs) { + return rhs < lhs; + } + template + SPROUT_CONSTEXPR inline bool operator<=(sprout::basic_string const& lhs, sprout::basic_string const& rhs) { + return !(rhs < lhs); + } + template + SPROUT_CONSTEXPR inline bool operator>=(sprout::basic_string const& lhs, sprout::basic_string const& rhs) { + return !(lhs < rhs); + } + + // + // swap + // + template + SPROUT_CONSTEXPR inline void swap(sprout::basic_string& lhs, sprout::basic_string& rhs) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) { + lhs.swap(rhs); + } + + // + // rebind_fixed_size + // + template + struct rebind_fixed_size > { + public: + template >::size_type S> + struct apply { + public: + typedef sprout::basic_string type; + }; + }; + + namespace detail { + template + struct is_basic_string_impl { + public: + typedef std::integral_constant type; + SPROUT_STATIC_CONSTEXPR bool value = type::value; + }; + template + struct is_basic_string_impl< + T, + typename std::enable_if< + std::is_same< + T, + sprout::basic_string + >::value + >::type + > { + public: + typedef std::integral_constant type; + SPROUT_STATIC_CONSTEXPR bool value = type::value; + }; + } // namespace detail + // + // is_basic_string + // + template + struct is_basic_string + : public sprout::detail::is_basic_string_impl + {}; + + namespace detail { + template + struct is_string_of_impl { + public: + typedef std::integral_constant type; + SPROUT_STATIC_CONSTEXPR bool value = type::value; + }; + template + struct is_string_of_impl< + T, + typename std::enable_if< + std::is_same< + T, + sprout::basic_string + >::value + >::type + > { + public: + typedef std::integral_constant type; + SPROUT_STATIC_CONSTEXPR bool value = type::value; + }; + } // namespace detail + // + // is_string_of + // + template + struct is_string_of + : public sprout::detail::is_string_of_impl + {}; + + // + // is_string + // + template + struct is_string + : public sprout::is_string_of + {}; + // + // is_wstring + // + template + struct is_wstring + : public sprout::is_string_of + {}; + // + // is_u16string + // + template + struct is_u16string + : public sprout::is_string_of + {}; + // + // is_u32string + // + template + struct is_u32string + : public sprout::is_string_of + {}; + + namespace detail { + template + SPROUT_CONSTEXPR inline sprout::basic_string to_string_impl( + T const(& arr)[N], + sprout::index_tuple + ) + { + return sprout::basic_string{arr[Indexes]...}; + } + } // namespace detail + // + // to_string + // + template + SPROUT_CONSTEXPR inline sprout::basic_string to_string(T const(& arr)[N]) { + return sprout::detail::to_string_impl(arr, typename sprout::index_range<0, N - 1>::type()); + } + + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::push_back, T>::type operator+( + sprout::basic_string const& lhs, + T const& rhs + ) + { + return sprout::fixed::push_back(lhs, rhs); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::push_front, T>::type operator+( + T const& lhs, + sprout::basic_string const& rhs + ) + { + return sprout::fixed::push_front(rhs, lhs); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::join_back< + sprout::basic_string, + sprout::basic_string + >::type operator+( + sprout::basic_string const& lhs, + T const (& rhs)[N2] + ) + { + return sprout::fixed::join_back(lhs, sprout::to_string(rhs)); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::join_front< + sprout::basic_string, + sprout::basic_string + >::type operator+( + T const (& lhs)[N2], + sprout::basic_string const& rhs + ) + { + return sprout::fixed::join_front(rhs, sprout::to_string(lhs)); + } + template + SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::join_back< + sprout::basic_string, + sprout::basic_string + >::type operator+( + sprout::basic_string const& lhs, + sprout::basic_string const& rhs + ) + { + return sprout::fixed::join_back(lhs, rhs); + } + + template + SPROUT_CONSTEXPR inline std::enable_if< + sprout::is_string_of< + typename sprout::fixed_container_traits >::internal_type, + T + >::value, + typename sprout::fit::result_of::realine< + typename sprout::fixed::result_of::join_back< + sprout::sub_array, + sprout::basic_string + >::type + >::type + >::type operator+( + sprout::sub_array const& lhs, + T const (& rhs)[N2] + ) + { + return sprout::fit::realine(sprout::fixed::join_back(lhs, sprout::to_string(rhs))); + } + template + SPROUT_CONSTEXPR inline std::enable_if< + sprout::is_string_of< + typename sprout::fixed_container_traits >::internal_type, + T + >::value, + typename sprout::fit::result_of::realine< + typename sprout::fixed::result_of::join_front< + sprout::sub_array, + sprout::basic_string + >::type + >::type + >::type operator+( + T const (& lhs)[N2], + sprout::sub_array const& rhs + ) + { + return sprout::fit::realine(sprout::fixed::join_front(rhs, sprout::to_string(lhs))); + } + template + SPROUT_CONSTEXPR inline std::enable_if< + std::is_same< + typename sprout::fixed_container_traits >::internal_type::value_type, + typename sprout::fixed_container_traits >::internal_type::value_type + >::value + && sprout::is_basic_string >::internal_type>::value + && sprout::is_basic_string >::internal_type>::value + , + typename sprout::fit::result_of::realine< + typename sprout::fixed::result_of::join_back< + sprout::sub_array, + sprout::sub_array + >::type + >::type + >::type operator+( + sprout::sub_array const& lhs, + sprout::sub_array const& rhs + ) + { + return sprout::fit::realine(sprout::fixed::join_back(lhs, rhs)); + } + + template + inline std::basic_ostream& operator<<(std::basic_ostream& lhs, sprout::basic_string const& rhs) { + return lhs << rhs.c_str(); + } + +#if 0 + // + // string + // + template + using string = sprout::basic_string; + // + // wstring + // + template + using wstring = sprout::basic_string; + // + // u16string + // + template + using u16string = sprout::basic_string; + // + // u32string + // + template + using u32string = sprout::basic_string; +#endif // #if 0 + + // + // string_t + // + template + struct string_t { + public: + typedef sprout::basic_string type; + }; + // + // wstring_t + // + template + struct wstring_t { + public: + typedef sprout::basic_string type; + }; + // + // u16string_t + // + template + struct u16string_t { + public: + typedef sprout::basic_string type; + }; + // + // u32string_t + // + template + struct u32string_t { + public: + typedef sprout::basic_string type; + }; +} // namespace sprout + +namespace std { + // + // tuple_size + // + template + struct tuple_size > { + public: + typedef std::integral_constant type; + SPROUT_STATIC_CONSTEXPR std::size_t value = type::value; + }; + + // + // tuple_element + // + template + struct tuple_element > { + public: + static_assert(I < N, "tuple_element<>: index out of range"); + typedef T type; + }; + + // + // get + // + template + T& get(sprout::basic_string& arr) SPROUT_NOEXCEPT { + static_assert(I < N, "tuple_element<>: index out of range"); + return arr[I]; + } + template + SPROUT_CONSTEXPR T const& get(sprout::basic_string const& arr) SPROUT_NOEXCEPT { + static_assert(I < N, "tuple_element<>: index out of range"); + return arr[I]; + } + template + T&& get(sprout::basic_string&& arr) SPROUT_NOEXCEPT { + return std::move(get(arr)); + } +} // namespace std + +#endif // #ifndef SPROUT_STRING_HPP diff --git a/sprout/sprout/sub_array.hpp b/sprout/sprout/sub_array.hpp new file mode 100644 index 00000000..8bf5c63a --- /dev/null +++ b/sprout/sprout/sub_array.hpp @@ -0,0 +1,936 @@ +#ifndef SPROUT_SUB_ARRAY_HPP +#define SPROUT_SUB_ARRAY_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace detail { + struct is_non_reference_array_tag {}; + struct is_not_non_reference_array_tag {}; + + template + class sub_array_impl { + protected: + typedef Container container_type; + typedef typename std::remove_reference::type fixed_container_type; + typedef typename std::remove_const::type internal_type; + protected: + SPROUT_STATIC_CONSTEXPR bool is_reference = std::is_reference::value; + SPROUT_STATIC_CONSTEXPR bool is_const = std::is_const::value; + protected: + typedef typename sprout::fixed_container_traits::value_type value_type; + typedef typename sprout::detail::if_c< + is_const, + typename sprout::fixed_container_traits::const_iterator, + typename sprout::fixed_container_traits::iterator + >::type iterator; + typedef typename sprout::fixed_container_traits::const_iterator const_iterator; + typedef typename sprout::detail::if_c< + is_const, + typename sprout::fixed_container_traits::const_reference, + typename sprout::fixed_container_traits::reference + >::type reference; + typedef typename sprout::fixed_container_traits::const_reference const_reference; + typedef typename sprout::fixed_container_traits::size_type size_type; + typedef typename sprout::fixed_container_traits::difference_type difference_type; + typedef typename sprout::detail::if_c< + is_const, + typename sprout::fixed_container_traits::const_pointer, + typename sprout::fixed_container_traits::pointer + >::type pointer; + typedef typename sprout::fixed_container_traits::const_pointer const_pointer; + protected: + SPROUT_STATIC_CONSTEXPR size_type static_size = sprout::fixed_container_traits::fixed_size; + SPROUT_STATIC_CONSTEXPR size_type fixed_size = static_size; + protected: + typedef typename sprout::detail::if_c< + is_reference, + fixed_container_type*, + typename std::remove_const::type + >::type holder_type; + typedef typename sprout::detail::if_c< + is_reference, + fixed_container_type&, + fixed_container_type const& + >::type param_type; + typedef fixed_container_type const& const_param_type; + protected: + typedef typename sprout::detail::if_c< + std::is_array::value, + sprout::detail::is_non_reference_array_tag, + sprout::detail::is_not_non_reference_array_tag + >::type array_tag; + protected: + template + static SPROUT_CONSTEXPR typename std::enable_if< + std::is_reference::value, + holder_type + >::type to_holder(param_type arr) { + return &arr; + } + template + static SPROUT_CONSTEXPR typename std::enable_if< + !std::is_reference::value, + holder_type const& + >::type to_holder(param_type arr) { + return arr; + } + template + static SPROUT_CONSTEXPR typename std::enable_if< + std::is_reference::value, + param_type + >::type to_param(holder_type arr) { + return *arr; + } + template + static SPROUT_CONSTEXPR typename std::enable_if< + !std::is_reference::value, + param_type + >::type to_param(holder_type& arr) { + return arr; + } + template + static SPROUT_CONSTEXPR typename std::enable_if< + !std::is_reference::value, + param_type + >::type to_param(holder_type const& arr) { + return arr; + } + template + static SPROUT_CONSTEXPR typename std::enable_if< + std::is_reference::value, + const_param_type + >::type to_const_param(holder_type arr) { + return *arr; + } + template + static SPROUT_CONSTEXPR typename std::enable_if< + !std::is_reference::value, + const_param_type + >::type to_const_param(holder_type const& arr) { + return arr; + } + protected: + holder_type array_; + difference_type first_; + difference_type last_; + public: + sub_array_impl() = default; + protected: + template + SPROUT_CONSTEXPR sub_array_impl( + ContainerTag, + param_type arr, + sprout::index_tuple, + const_iterator first, + const_iterator last, + typename std::enable_if::value>::type* = 0 + ) + : array_{to_holder(arr)[Indexes]...} + , first_(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::cbegin(arr), first)) + , last_(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::cbegin(arr), last)) + {} + template + SPROUT_CONSTEXPR sub_array_impl( + ContainerTag, + param_type arr, + sprout::index_tuple, + const_iterator first, + const_iterator last, + typename std::enable_if::value>::type* = 0 + ) + : array_(to_holder(arr)) + , first_(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::cbegin(arr), first)) + , last_(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::cbegin(arr), last)) + {} + template + SPROUT_CONSTEXPR sub_array_impl( + ContainerTag, + param_type arr, + sprout::index_tuple, + difference_type first, + difference_type last, + typename std::enable_if::value>::type* = 0 + ) + : array_{to_holder(arr)[Indexes]...} + , first_(first) + , last_(last) + {} + template + SPROUT_CONSTEXPR sub_array_impl( + ContainerTag, + param_type arr, + sprout::index_tuple, + difference_type first, + difference_type last, + typename std::enable_if::value>::type* = 0 + ) + : array_(to_holder(arr)) + , first_(first) + , last_(last) + {} + }; + } // namespace detail + + // + // sub_array + // + template + class sub_array + : private sprout::detail::sub_array_impl + { + private: + typedef sprout::detail::sub_array_impl impl_type; + public: + typedef typename impl_type::container_type container_type; + typedef typename impl_type::fixed_container_type fixed_container_type; + typedef typename impl_type::internal_type internal_type; + typedef sub_array::clone_type> clone_type; + public: + SPROUT_STATIC_CONSTEXPR bool is_reference = impl_type::is_reference; + SPROUT_STATIC_CONSTEXPR bool is_const = impl_type::is_const; + public: + typedef typename impl_type::value_type value_type; + typedef typename impl_type::iterator iterator; + typedef typename impl_type::const_iterator const_iterator; + typedef typename impl_type::reference reference; + typedef typename impl_type::const_reference const_reference; + typedef typename impl_type::size_type size_type; + typedef typename impl_type::difference_type difference_type; + typedef typename impl_type::pointer pointer; + typedef typename impl_type::const_pointer const_pointer; + public: + SPROUT_STATIC_CONSTEXPR size_type static_size = impl_type::static_size; + SPROUT_STATIC_CONSTEXPR size_type fixed_size = impl_type::fixed_size; + public: + typedef typename impl_type::holder_type holder_type; + typedef typename impl_type::param_type param_type; + typedef typename impl_type::const_param_type const_param_type; + private: + typedef typename impl_type::array_tag array_tag; + private: + using impl_type::array_; + using impl_type::first_; + using impl_type::last_; + public: + sub_array() = default; + SPROUT_CONSTEXPR sub_array(param_type arr, const_iterator first, const_iterator last) + : impl_type( + array_tag(), + arr, + typename sprout::index_range<0, fixed_size>::type(), + first, + last + ) + {} + SPROUT_CONSTEXPR sub_array(param_type arr, difference_type first, difference_type last) + : impl_type( + array_tag(), + arr, + typename sprout::index_range<0, fixed_size>::type(), + first, + last + ) + {} + SPROUT_CONSTEXPR sub_array(sub_array const& other, const_iterator first, const_iterator last) + : impl_type( + array_tag(), + impl_type::template to_param(other.array_), + typename sprout::index_range<0, fixed_size>::type(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(other.get_array()), first), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(other.get_array()), last) + ) + {} + SPROUT_CONSTEXPR sub_array(sub_array const& other, difference_type first, difference_type last) + : impl_type( + array_tag(), + impl_type::template to_param(other.array_), + typename sprout::index_range<0, fixed_size>::type(), + first + other.first_, + last + other.first_ + ) + {} + param_type get_fixed() { + return impl_type::template to_param(array_); + } + SPROUT_CONSTEXPR const_param_type get_fixed() const { + return impl_type::template to_const_param(array_); + } + SPROUT_CONSTEXPR const_param_type get_cfixed() const { + return impl_type::template to_const_param(array_); + } + param_type get_array() { + return impl_type::template to_param(array_); + } + SPROUT_CONSTEXPR const_param_type get_array() const { + return impl_type::template to_const_param(array_); + } + SPROUT_CONSTEXPR size_type size() const { + return last_ - first_; + } + SPROUT_CONSTEXPR bool empty() const { + return size() != 0; + } + SPROUT_CONSTEXPR size_type max_size() const { + return size(); + } + void rangecheck(size_type i) const { + if (i >= size()) { + throw std::out_of_range("sub_array<>: index out of range"); + } + } + iterator begin() { + return sprout::begin(get_array()) + first_; + } + SPROUT_CONSTEXPR const_iterator begin() const { + return sprout::begin(get_array()) + first_; + } + SPROUT_CONSTEXPR const_iterator cbegin() const { + return sprout::begin(get_array()) + first_; + } + iterator end() { + return sprout::begin(get_array()) + last_; + } + SPROUT_CONSTEXPR const_iterator end() const { + return sprout::begin(get_array()) + last_; + } + SPROUT_CONSTEXPR const_iterator cend() const { + return sprout::begin(get_array()) + last_; + } + reference operator[](size_type i) { + return *(sprout::begin(get_array()) + first_ + i); + } + SPROUT_CONSTEXPR const_reference operator[](size_type i) const { + return *(sprout::begin(get_array()) + first_ + i); + } + reference at(size_type i) { + rangecheck(i); + return *(sprout::begin(get_array()) + first_ + i); + } + const_reference at(size_type i) const { + rangecheck(i); + return *(sprout::begin(get_array()) + first_ + i); + } + reference front() { + return *(sprout::begin(get_array()) + first_); + } + SPROUT_CONSTEXPR const_reference front() const { + return *(sprout::begin(get_array()) + first_); + } + reference back() { + return *(sprout::begin(get_array()) + (last_ - 1)); + } + SPROUT_CONSTEXPR const_reference back() const { + return *(sprout::begin(get_array()) + (last_ - 1)); + } + pointer data() { + return get_array().data() + first_; + } + SPROUT_CONSTEXPR const_pointer data() const { + return get_array().data() + first_; + } + pointer c_array() { + return data(); + } + void assign (const_reference value) { + fill(value); + } + void fill(const_reference value) { + std::fill_n(begin(), size(), value); + } + template + void swap(sub_array& other) { + using std::swap; + swap(other.array_, array_); + swap(other.first_, first_); + swap(other.last_, last_); + } + template + sub_array& operator=(sub_array const& rhs) { + array_ = rhs.array_; + first_ = rhs.first_; + last_ = rhs.last_; + return *this; + } + template + sub_array& operator=(sub_array&& rhs) { + array_ = std::move(rhs.array_); + first_ = std::move(rhs.first_); + last_ = std::move(rhs.last_); + return *this; + } + }; + template + SPROUT_CONSTEXPR inline bool operator==(sprout::sub_array const& lhs, sprout::sub_array const& rhs) { + return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::equal(sprout::begin(lhs), sprout::end(lhs), sprout::begin(rhs)); + } + template + SPROUT_CONSTEXPR inline bool operator!=(sprout::sub_array const& lhs, sprout::sub_array const& rhs) { + return !(lhs == rhs); + } + template + SPROUT_CONSTEXPR inline bool operator<(sprout::sub_array const& lhs, sprout::sub_array const& rhs) { + return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::lexicographical_compare(sprout::begin(lhs), sprout::end(lhs), sprout::begin(rhs), sprout::end(rhs)); + } + template + SPROUT_CONSTEXPR inline bool operator>(sprout::sub_array const& lhs, sprout::sub_array const& rhs) { + return rhs < lhs; + } + template + SPROUT_CONSTEXPR inline bool operator<=(sprout::sub_array const& lhs, sprout::sub_array const& rhs) { + return !(rhs < lhs); + } + template + SPROUT_CONSTEXPR inline bool operator>=(sprout::sub_array const& lhs, sprout::sub_array const& rhs) { + return !(lhs < rhs); + } + + // + // swap + // + template + SPROUT_CONSTEXPR inline void swap(sprout::sub_array& lhs, sprout::sub_array& rhs) { + lhs.swap(rhs); + } + + // + // fixed_container_traits + // + template + struct fixed_container_traits > + : public sprout::detail::fixed_container_traits_base > + { + public: + typedef typename sprout::sub_array::fixed_container_type fixed_container_type; + typedef typename sprout::sub_array::internal_type internal_type; + typedef typename sprout::sub_array::clone_type clone_type; + public: + SPROUT_STATIC_CONSTEXPR typename sprout::detail::fixed_container_traits_base >::size_type fixed_size + = std::tuple_size::type>::value + ; + }; + + // + // rebind_fixed_size + // + template + struct rebind_fixed_size > { + public: + template >::size_type S> + struct apply { + public: + typedef sprout::sub_array< + typename sprout::rebind_fixed_size< + typename sprout::fixed_container_traits >::internal_type + >::template apply::type + > type; + }; + }; + + // + // get_fixed_functor + // + template + struct get_fixed_functor > { + private: + typedef typename sprout::fixed_container_traits >::fixed_container_type fixed_container_type; + public: + fixed_container_type& operator()(sprout::sub_array& cont) const { + return cont.get_fixed(); + } + SPROUT_CONSTEXPR fixed_container_type const& operator()(sprout::sub_array const& cont) const { + return cont.get_fixed(); + } + }; + + // + // clone_functor + // + template + struct clone_functor > { + private: + typedef typename sprout::fixed_container_traits >::clone_type clone_type; + public: + clone_type operator()(sprout::sub_array& cont) const { + return clone_type(sprout::clone(sprout::get_fixed(cont)), sprout::fixed_begin_offset(cont), sprout::fixed_end_offset(cont)); + } + SPROUT_CONSTEXPR clone_type operator()(sprout::sub_array const& cont) const { + return clone_type(sprout::clone(sprout::get_fixed(cont)), sprout::fixed_begin_offset(cont), sprout::fixed_end_offset(cont)); + } + }; + + // + // make_clone_functor + // + template + struct make_clone_functor > { + private: + typedef typename sprout::fixed_container_traits >::clone_type clone_type; + typedef typename sprout::fixed_container_traits >::internal_type internal_type; + private: + SPROUT_CONSTEXPR clone_type make(typename sprout::fixed_container_traits::clone_type const& arr) const { + return clone_type(arr, sprout::begin(arr), sprout::end(arr)); + } + public: + template + SPROUT_CONSTEXPR clone_type operator()(Args const&... args) const { + return make(sprout::make_clone(args...)); + } + }; + + // + // remake_clone_functor + // + template + struct remake_clone_functor > { + private: + typedef typename sprout::fixed_container_traits >::clone_type clone_type; + typedef typename sprout::fixed_container_traits >::internal_type internal_type; + private: + template + clone_type remake( + Other& other, + typename sprout::fixed_container_traits >::difference_type size, + typename sprout::fixed_container_traits::clone_type const& cloned + ) const + { + return clone_type( + cloned, + sprout::begin(cloned) + sprout::fixed_begin_offset(other), + sprout::begin(cloned) + sprout::fixed_begin_offset(other) + size + ); + } + template + SPROUT_CONSTEXPR clone_type remake( + Other const& other, + typename sprout::fixed_container_traits >::difference_type size, + typename sprout::fixed_container_traits::clone_type const& cloned + ) const + { + return clone_type( + cloned, + sprout::begin(cloned) + sprout::fixed_begin_offset(other), + sprout::begin(cloned) + sprout::fixed_begin_offset(other) + size + ); + } + public: + template + clone_type operator()( + Other& other, + typename sprout::fixed_container_traits >::difference_type size, + Args const&... args + ) const + { + return remake(other, size, sprout::make_clone(args...)); + } + template + SPROUT_CONSTEXPR clone_type operator()( + Other const& other, + typename sprout::fixed_container_traits >::difference_type size, + Args const&... args + ) const + { + return remake(other, size, sprout::make_clone(args...)); + } + }; + + namespace detail { + template + struct is_sub_array_impl { + public: + typedef std::integral_constant type; + SPROUT_STATIC_CONSTEXPR bool value = type::value; + }; + template + struct is_sub_array_impl< + T, + typename std::enable_if< + std::is_same< + T, + sprout::sub_array + >::value + >::type + > { + public: + typedef std::integral_constant type; + SPROUT_STATIC_CONSTEXPR bool value = type::value; + }; + } // namespace detail + // + // is_sub_array + // + template + struct is_sub_array + : public sprout::detail::is_sub_array_impl + {}; + + // + // sub + // + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub( + Container& arr, + typename sprout::fixed_container_traits >::const_iterator first, + typename sprout::fixed_container_traits >::const_iterator last + ) + { + return sprout::sub_array(arr, first, last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub( + Container& arr, + typename sprout::fixed_container_traits >::difference_type first, + typename sprout::fixed_container_traits >::difference_type last + ) + { + return sprout::sub_array(arr, first, last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub( + Container& arr, + typename sprout::fixed_container_traits >::const_iterator first + ) + { + return sprout::sub(arr, first, sprout::end(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub( + Container& arr, + typename sprout::fixed_container_traits >::difference_type first + ) + { + return sprout::sub(arr, first, sprout::size(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub( + Container& arr + ) + { + return sprout::sub(arr, sprout::begin(arr), sprout::end(arr)); + } + // + // sub + // + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub( + Container const& arr, + typename sprout::fixed_container_traits >::const_iterator first, + typename sprout::fixed_container_traits >::const_iterator last + ) + { + return sprout::sub_array(arr, first, last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub( + Container const& arr, + typename sprout::fixed_container_traits >::difference_type first, + typename sprout::fixed_container_traits >::difference_type last + ) + { + return sprout::sub_array(arr, first, last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub( + Container const& arr, + typename sprout::fixed_container_traits >::const_iterator first + ) + { + return sprout::sub(arr, first, sprout::end(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub( + Container const& arr, + typename sprout::fixed_container_traits >::difference_type first + ) + { + return sprout::sub(arr, first, sprout::size(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub( + Container const& arr + ) + { + return sprout::sub(arr, sprout::begin(arr), sprout::end(arr)); + } + // + // sub + // + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, Container>::type sub( + Container const& arr, + typename sprout::fixed_container_traits::const_iterator first, + typename sprout::fixed_container_traits::const_iterator last + ) + { + return Container(arr, first, last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, Container>::type sub( + Container const& arr, + typename sprout::fixed_container_traits::difference_type first, + typename sprout::fixed_container_traits::difference_type last + ) + { + return Container(arr, first, last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, Container>::type sub( + Container const& arr, + typename sprout::fixed_container_traits::const_iterator first + ) + { + return sprout::sub(arr, first, sprout::end(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, Container>::type sub( + Container const& arr, + typename sprout::fixed_container_traits::difference_type first + ) + { + return sprout::sub(arr, first, sprout::size(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, Container>::type sub( + Container const& arr + ) + { + return sprout::sub(arr, sprout::begin(arr), sprout::end(arr)); + } + + // + // csub + // + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type csub( + Container const& arr, + typename sprout::fixed_container_traits >::const_iterator first, + typename sprout::fixed_container_traits >::const_iterator last + ) + { + return sprout::sub_array(arr, first, last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type csub( + Container const& arr, + typename sprout::fixed_container_traits >::difference_type first, + typename sprout::fixed_container_traits >::difference_type last + ) + { + return sprout::sub_array(arr, first, last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type csub( + Container const& arr, + typename sprout::fixed_container_traits >::const_iterator first + ) + { + return sprout::csub(arr, first, sprout::end(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type csub( + Container const& arr, + typename sprout::fixed_container_traits >::difference_type first + ) + { + return sprout::csub(arr, first, sprout::size(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type csub( + Container const& arr + ) + { + return sprout::csub(arr, sprout::begin(arr), sprout::end(arr)); + } + // + // csub + // + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type csub( + Container const& arr, + typename sprout::fixed_container_traits::const_iterator first, + typename sprout::fixed_container_traits::const_iterator last + ) + { + return sprout::sub_array(arr.get_array(), first, last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type csub( + Container const& arr, + typename sprout::fixed_container_traits::difference_type first, + typename sprout::fixed_container_traits::difference_type last + ) + { + return sprout::sub_array(arr.get_array(), sprout::begin(arr) + first, sprout::begin(arr) + last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type csub( + Container const& arr, + typename sprout::fixed_container_traits::const_iterator first + ) + { + return sprout::csub(arr, first, sprout::end(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type csub( + Container const& arr, + typename sprout::fixed_container_traits::difference_type first + ) + { + return sprout::csub(arr, first, sprout::size(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type csub( + Container const& arr + ) + { + return sprout::csub(arr, sprout::begin(arr), sprout::end(arr)); + } + + // + // sub_copy + // + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub_copy( + Container const& arr, + typename sprout::fixed_container_traits::const_iterator first, + typename sprout::fixed_container_traits::const_iterator last + ) + { + return sprout::sub_array(arr, first, last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub_copy( + Container const& arr, + typename sprout::fixed_container_traits::difference_type first, + typename sprout::fixed_container_traits::difference_type last + ) + { + return sprout::sub_array(arr, first, last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub_copy( + Container const& arr, + typename sprout::fixed_container_traits::const_iterator first + ) + { + return sprout::sub_copy(arr, first, sprout::end(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub_copy( + Container const& arr, + typename sprout::fixed_container_traits::difference_type first + ) + { + return sprout::sub_copy(arr, first, sprout::size(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub_copy( + Container const& arr + ) + { + return sprout::sub_copy(arr, sprout::begin(arr), sprout::end(arr)); + } + // + // sub_copy + // + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub_copy( + Container const& arr, + typename sprout::fixed_container_traits::const_iterator first, + typename sprout::fixed_container_traits::const_iterator last + ) + { + return sprout::sub_array(arr.get_array(), first, last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub_copy( + Container const& arr, + typename sprout::fixed_container_traits::difference_type first, + typename sprout::fixed_container_traits::difference_type last + ) + { + return sprout::sub_array(arr.get_array(), sprout::begin(arr) + first, sprout::begin(arr) + last); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub_copy( + Container const& arr, + typename sprout::fixed_container_traits::const_iterator first + ) + { + return sprout::sub_copy(arr, first, sprout::end(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub_copy( + Container const& arr, + typename sprout::fixed_container_traits::difference_type first + ) + { + return sprout::sub_copy(arr, first, sprout::size(arr)); + } + template + SPROUT_CONSTEXPR inline typename std::enable_if::value, sprout::sub_array >::type sub_copy( + Container const& arr + ) + { + return sprout::sub_copy(arr, sprout::begin(arr), sprout::end(arr)); + } +} // namespace sprout + +namespace std { + // + // tuple_size + // + template + struct tuple_size > { + public: + SPROUT_STATIC_CONSTEXPR std::size_t value = std::tuple_size< + typename std::remove_const< + typename std::remove_reference::type + >::type + >::value; + }; + + // + // tuple_element + // + template + struct tuple_element > { + public: + typedef typename std::tuple_element< + I, + typename std::remove_const< + typename std::remove_reference::type + >::type + >::type type; + }; + + // + // get + // + template + T& get(sprout::sub_array& arr) SPROUT_NOEXCEPT { + static_assert(I < sprout::fixed_container_traits >::fixed_size, "tuple_element<>: index out of range"); + return *(sprout::fixed_begin(arr) + I); + } + template + SPROUT_CONSTEXPR T const& get(sprout::sub_array const& arr) SPROUT_NOEXCEPT { + static_assert(I < sprout::fixed_container_traits >::fixed_size, "tuple_element<>: index out of range"); + return *(sprout::fixed_begin(arr) + I); + } + template + T&& get(sprout::sub_array&& arr) SPROUT_NOEXCEPT { + return std::move(get(arr)); + } +} // namespace std + +#endif // #ifndef SPROUT_SUB_ARRAY_HPP diff --git a/sprout/user_config.hpp b/sprout/user_config.hpp new file mode 100644 index 00000000..c0a86f4e --- /dev/null +++ b/sprout/user_config.hpp @@ -0,0 +1,4 @@ + +//#define SPROUT_CONFIG_DISABLE_CONSTEXPR +//#define SPROUT_CONFIG_DISABLE_NOEXCEPT +//#define SPROUT_CONFIG_USE_SSCRISK_CEL