From 040278bd119e47e06915dfb215f8818bfd43a7f0 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Thu, 31 Oct 2013 18:57:41 +0900 Subject: [PATCH] add new directory sprout/algorithm/cxx14/ --- sprout/algorithm/copy.hpp | 21 +------ sprout/algorithm/copy_backward.hpp | 21 +------ sprout/algorithm/copy_if.hpp | 23 +------ sprout/algorithm/copy_n.hpp | 21 +------ sprout/algorithm/cxx14.hpp | 45 +++++++++++++ sprout/algorithm/cxx14/copy.hpp | 32 ++++++++++ sprout/algorithm/cxx14/copy_backward.hpp | 32 ++++++++++ sprout/algorithm/cxx14/copy_if.hpp | 34 ++++++++++ sprout/algorithm/cxx14/copy_n.hpp | 32 ++++++++++ sprout/algorithm/cxx14/fill.hpp | 26 ++++++++ sprout/algorithm/cxx14/fill_n.hpp | 32 ++++++++++ sprout/algorithm/cxx14/generate.hpp | 26 ++++++++ sprout/algorithm/cxx14/generate_n.hpp | 30 +++++++++ sprout/algorithm/cxx14/iter_swap.hpp | 25 ++++++++ sprout/algorithm/cxx14/move.hpp | 33 ++++++++++ sprout/algorithm/cxx14/move_backward.hpp | 33 ++++++++++ sprout/algorithm/cxx14/partition.hpp | 34 ++++++++++ sprout/algorithm/cxx14/partition_copy.hpp | 23 +++++++ sprout/algorithm/cxx14/random_shuffle.hpp | 30 +++++++++ sprout/algorithm/cxx14/remove.hpp | 31 +++++++++ sprout/algorithm/cxx14/remove_copy.hpp | 34 ++++++++++ sprout/algorithm/cxx14/remove_copy_if.hpp | 34 ++++++++++ sprout/algorithm/cxx14/remove_if.hpp | 31 +++++++++ sprout/algorithm/cxx14/replace.hpp | 28 +++++++++ sprout/algorithm/cxx14/replace_copy.hpp | 32 ++++++++++ sprout/algorithm/cxx14/replace_copy_if.hpp | 32 ++++++++++ sprout/algorithm/cxx14/replace_if.hpp | 28 +++++++++ sprout/algorithm/cxx14/reverse.hpp | 27 ++++++++ sprout/algorithm/cxx14/reverse_copy.hpp | 32 ++++++++++ sprout/algorithm/cxx14/rotate.hpp | 58 +++++++++++++++++ sprout/algorithm/cxx14/rotate_copy.hpp | 30 +++++++++ sprout/algorithm/cxx14/shuffle.hpp | 22 +++++++ sprout/algorithm/cxx14/stable_partition.hpp | 22 +++++++ sprout/algorithm/cxx14/swap_ranges.hpp | 28 +++++++++ sprout/algorithm/cxx14/transform.hpp | 43 +++++++++++++ sprout/algorithm/cxx14/unique.hpp | 55 ++++++++++++++++ sprout/algorithm/cxx14/unique_copy.hpp | 61 ++++++++++++++++++ sprout/algorithm/fill.hpp | 15 +---- sprout/algorithm/fill_n.hpp | 21 +------ sprout/algorithm/generate.hpp | 15 +---- sprout/algorithm/generate_n.hpp | 19 +----- sprout/algorithm/iter_swap.hpp | 13 +--- sprout/algorithm/modifying.hpp | 70 +-------------------- sprout/algorithm/move.hpp | 21 +------ sprout/algorithm/move_backward.hpp | 21 +------ sprout/algorithm/partition.hpp | 23 +------ sprout/algorithm/partition_copy.hpp | 12 +--- sprout/algorithm/random_shuffle.hpp | 18 +----- sprout/algorithm/remove.hpp | 20 +----- sprout/algorithm/remove_copy.hpp | 23 +------ sprout/algorithm/remove_copy_if.hpp | 23 +------ sprout/algorithm/remove_if.hpp | 20 +----- sprout/algorithm/replace.hpp | 17 +---- sprout/algorithm/replace_copy.hpp | 21 +------ sprout/algorithm/replace_copy_if.hpp | 21 +------ sprout/algorithm/replace_if.hpp | 17 +---- sprout/algorithm/reverse.hpp | 16 +---- sprout/algorithm/reverse_copy.hpp | 21 +------ sprout/algorithm/rotate.hpp | 47 +------------- sprout/algorithm/rotate_copy.hpp | 19 +----- sprout/algorithm/shuffle.hpp | 11 +--- sprout/algorithm/stable_partition.hpp | 12 +--- sprout/algorithm/swap_ranges.hpp | 16 +---- sprout/algorithm/transform.hpp | 32 +--------- sprout/algorithm/unique.hpp | 44 +------------ sprout/algorithm/unique_copy.hpp | 50 +-------------- sprout/array/array.hpp | 8 +-- sprout/bitset/bitset.hpp | 9 ++- sprout/functional/bind/bind.hpp | 4 +- sprout/range/range_container.hpp | 6 +- sprout/string/char_traits.hpp | 7 +-- sprout/string/string.hpp | 2 +- sprout/sub_array/sub_array.hpp | 11 ++-- sprout/utility/string_ref/io.hpp | 4 +- sprout/uuid/io.hpp | 9 +-- sprout/uuid/uuid.hpp | 7 ++- 76 files changed, 1165 insertions(+), 761 deletions(-) create mode 100644 sprout/algorithm/cxx14.hpp create mode 100644 sprout/algorithm/cxx14/copy.hpp create mode 100644 sprout/algorithm/cxx14/copy_backward.hpp create mode 100644 sprout/algorithm/cxx14/copy_if.hpp create mode 100644 sprout/algorithm/cxx14/copy_n.hpp create mode 100644 sprout/algorithm/cxx14/fill.hpp create mode 100644 sprout/algorithm/cxx14/fill_n.hpp create mode 100644 sprout/algorithm/cxx14/generate.hpp create mode 100644 sprout/algorithm/cxx14/generate_n.hpp create mode 100644 sprout/algorithm/cxx14/iter_swap.hpp create mode 100644 sprout/algorithm/cxx14/move.hpp create mode 100644 sprout/algorithm/cxx14/move_backward.hpp create mode 100644 sprout/algorithm/cxx14/partition.hpp create mode 100644 sprout/algorithm/cxx14/partition_copy.hpp create mode 100644 sprout/algorithm/cxx14/random_shuffle.hpp create mode 100644 sprout/algorithm/cxx14/remove.hpp create mode 100644 sprout/algorithm/cxx14/remove_copy.hpp create mode 100644 sprout/algorithm/cxx14/remove_copy_if.hpp create mode 100644 sprout/algorithm/cxx14/remove_if.hpp create mode 100644 sprout/algorithm/cxx14/replace.hpp create mode 100644 sprout/algorithm/cxx14/replace_copy.hpp create mode 100644 sprout/algorithm/cxx14/replace_copy_if.hpp create mode 100644 sprout/algorithm/cxx14/replace_if.hpp create mode 100644 sprout/algorithm/cxx14/reverse.hpp create mode 100644 sprout/algorithm/cxx14/reverse_copy.hpp create mode 100644 sprout/algorithm/cxx14/rotate.hpp create mode 100644 sprout/algorithm/cxx14/rotate_copy.hpp create mode 100644 sprout/algorithm/cxx14/shuffle.hpp create mode 100644 sprout/algorithm/cxx14/stable_partition.hpp create mode 100644 sprout/algorithm/cxx14/swap_ranges.hpp create mode 100644 sprout/algorithm/cxx14/transform.hpp create mode 100644 sprout/algorithm/cxx14/unique.hpp create mode 100644 sprout/algorithm/cxx14/unique_copy.hpp diff --git a/sprout/algorithm/copy.hpp b/sprout/algorithm/copy.hpp index 7772ad24..34755535 100644 --- a/sprout/algorithm/copy.hpp +++ b/sprout/algorithm/copy.hpp @@ -9,27 +9,8 @@ #define SPROUT_ALGORITHM_COPY_HPP #include -#include -#include - -namespace sprout { - // - // 25.3.1 Copy - // - template< - typename InputIterator, typename OutputIterator, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - copy(InputIterator first, InputIterator last, OutputIterator result) { - while (first != last) { - *result++ = *first++; - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_COPY_HPP diff --git a/sprout/algorithm/copy_backward.hpp b/sprout/algorithm/copy_backward.hpp index 26b9f59e..d0458957 100644 --- a/sprout/algorithm/copy_backward.hpp +++ b/sprout/algorithm/copy_backward.hpp @@ -9,27 +9,8 @@ #define SPROUT_ALGORITHM_COPY_BACKWARD_HPP #include -#include -#include - -namespace sprout { - // - // 25.3.1 Copy - // - template< - typename BidirectionalIterator1, typename BidirectionalIterator2, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR BidirectionalIterator2 - copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result) { - while (first != last) { - *--result = *--first; - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_COPY_BACKWARD_HPP diff --git a/sprout/algorithm/copy_if.hpp b/sprout/algorithm/copy_if.hpp index f7a3be8f..c7d015e2 100644 --- a/sprout/algorithm/copy_if.hpp +++ b/sprout/algorithm/copy_if.hpp @@ -9,29 +9,8 @@ #define SPROUT_ALGORITHM_COPY_IF_HPP #include -#include -#include - -namespace sprout { - // - // 25.3.1 Copy - // - template< - typename InputIterator, typename OutputIterator, typename Predicate, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred) { - for (; first != last; ++first) { - if (pred(*first)) { - *result++ = *first; - } - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_COPY_IF_HPP diff --git a/sprout/algorithm/copy_n.hpp b/sprout/algorithm/copy_n.hpp index 518f46de..b09a0e72 100644 --- a/sprout/algorithm/copy_n.hpp +++ b/sprout/algorithm/copy_n.hpp @@ -9,27 +9,8 @@ #define SPROUT_ALGORITHM_COPY_N_HPP #include -#include -#include - -namespace sprout { - // - // 25.3.1 Copy - // - template< - typename InputIterator, typename Size, typename OutputIterator, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - copy_n(InputIterator first, Size n, OutputIterator result) { - for (Size i = 0; i < n; ++i) { - *result++ = *first++; - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_COPY_N_HPP diff --git a/sprout/algorithm/cxx14.hpp b/sprout/algorithm/cxx14.hpp new file mode 100644 index 00000000..b792242b --- /dev/null +++ b/sprout/algorithm/cxx14.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_ALGORITHM_CXX14_HPP +#define SPROUT_ALGORITHM_CXX14_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 + +#endif // #ifndef SPROUT_ALGORITHM_CXX14_HPP diff --git a/sprout/algorithm/cxx14/copy.hpp b/sprout/algorithm/cxx14/copy.hpp new file mode 100644 index 00000000..5cdee523 --- /dev/null +++ b/sprout/algorithm/cxx14/copy.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_COPY_HPP +#define SPROUT_CXX14_ALGORITHM_COPY_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.1 Copy + // + template< + typename InputIterator, typename OutputIterator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + copy(InputIterator first, InputIterator last, OutputIterator result) { + while (first != last) { + *result++ = *first++; + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_COPY_HPP diff --git a/sprout/algorithm/cxx14/copy_backward.hpp b/sprout/algorithm/cxx14/copy_backward.hpp new file mode 100644 index 00000000..36ad3045 --- /dev/null +++ b/sprout/algorithm/cxx14/copy_backward.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_COPY_BACKWARD_HPP +#define SPROUT_CXX14_ALGORITHM_COPY_BACKWARD_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.1 Copy + // + template< + typename BidirectionalIterator1, typename BidirectionalIterator2, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR BidirectionalIterator2 + copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result) { + while (first != last) { + *--result = *--first; + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_COPY_BACKWARD_HPP diff --git a/sprout/algorithm/cxx14/copy_if.hpp b/sprout/algorithm/cxx14/copy_if.hpp new file mode 100644 index 00000000..550a58f3 --- /dev/null +++ b/sprout/algorithm/cxx14/copy_if.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_COPY_IF_HPP +#define SPROUT_CXX14_ALGORITHM_COPY_IF_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.1 Copy + // + template< + typename InputIterator, typename OutputIterator, typename Predicate, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred) { + for (; first != last; ++first) { + if (pred(*first)) { + *result++ = *first; + } + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_COPY_IF_HPP diff --git a/sprout/algorithm/cxx14/copy_n.hpp b/sprout/algorithm/cxx14/copy_n.hpp new file mode 100644 index 00000000..ebb36f23 --- /dev/null +++ b/sprout/algorithm/cxx14/copy_n.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_COPY_N_HPP +#define SPROUT_CXX14_ALGORITHM_COPY_N_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.1 Copy + // + template< + typename InputIterator, typename Size, typename OutputIterator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + copy_n(InputIterator first, Size n, OutputIterator result) { + for (Size i = 0; i < n; ++i) { + *result++ = *first++; + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_COPY_N_HPP diff --git a/sprout/algorithm/cxx14/fill.hpp b/sprout/algorithm/cxx14/fill.hpp new file mode 100644 index 00000000..97890b48 --- /dev/null +++ b/sprout/algorithm/cxx14/fill.hpp @@ -0,0 +1,26 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_FILL_HPP +#define SPROUT_CXX14_ALGORITHM_FILL_HPP + +#include + +namespace sprout { + // + // 25.3.6 Fill + // + template + inline SPROUT_CXX14_CONSTEXPR void + fill(ForwardIterator first, ForwardIterator last, T const& value) { + while (first != last) { + *first++ = value; + } + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_FILL_HPP diff --git a/sprout/algorithm/cxx14/fill_n.hpp b/sprout/algorithm/cxx14/fill_n.hpp new file mode 100644 index 00000000..9fdd56fa --- /dev/null +++ b/sprout/algorithm/cxx14/fill_n.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_FILL_N_HPP +#define SPROUT_CXX14_ALGORITHM_FILL_N_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.6 Fill + // + template< + typename OutputIterator, typename Size, typename T, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + fill_n(OutputIterator first, Size n, T const& value) { + while (n-- > 0) { + *first++ = value; + } + return first; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_FILL_N_HPP diff --git a/sprout/algorithm/cxx14/generate.hpp b/sprout/algorithm/cxx14/generate.hpp new file mode 100644 index 00000000..1e3592d5 --- /dev/null +++ b/sprout/algorithm/cxx14/generate.hpp @@ -0,0 +1,26 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_GENERATE_HPP +#define SPROUT_CXX14_ALGORITHM_GENERATE_HPP + +#include + +namespace sprout { + // + // 25.3.7 Generate + // + template + inline SPROUT_CXX14_CONSTEXPR void + generate(ForwardIterator first, ForwardIterator last, Generator gen) { + while (first != last) { + *first++ = gen(); + } + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_GENERATE_HPP diff --git a/sprout/algorithm/cxx14/generate_n.hpp b/sprout/algorithm/cxx14/generate_n.hpp new file mode 100644 index 00000000..d936b253 --- /dev/null +++ b/sprout/algorithm/cxx14/generate_n.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_GENERATE_N_HPP +#define SPROUT_CXX14_ALGORITHM_GENERATE_N_HPP + +#include + +namespace sprout { + // + // 25.3.7 Generate + // + template< + typename OutputIterator, typename Size, typename Generator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + generate_n(OutputIterator first, Size n, Generator gen) { + while (n-- > 0) { + *first++ = gen(); + } + return first; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_GENERATE_N_HPP diff --git a/sprout/algorithm/cxx14/iter_swap.hpp b/sprout/algorithm/cxx14/iter_swap.hpp new file mode 100644 index 00000000..6210a0fd --- /dev/null +++ b/sprout/algorithm/cxx14/iter_swap.hpp @@ -0,0 +1,25 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_ITER_SWAP_HPP +#define SPROUT_CXX14_ALGORITHM_ITER_SWAP_HPP + +#include +#include + +namespace sprout { + // + // 25.3.3 swap + // + template + inline SPROUT_CXX14_CONSTEXPR void + iter_swap(ForwardIterator1 a, ForwardIterator2 b) { + sprout::swap(*a, *b); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_ITER_SWAP_HPP diff --git a/sprout/algorithm/cxx14/move.hpp b/sprout/algorithm/cxx14/move.hpp new file mode 100644 index 00000000..f301fbc1 --- /dev/null +++ b/sprout/algorithm/cxx14/move.hpp @@ -0,0 +1,33 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_MOVE_HPP +#define SPROUT_CXX14_ALGORITHM_MOVE_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // 25.3.2 Move + // + template< + typename InputIterator, typename OutputIterator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + move(InputIterator first, InputIterator last, OutputIterator result) { + while (first != last) { + *result++ = sprout::move(*first++); + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_MOVE_HPP diff --git a/sprout/algorithm/cxx14/move_backward.hpp b/sprout/algorithm/cxx14/move_backward.hpp new file mode 100644 index 00000000..a8902b9c --- /dev/null +++ b/sprout/algorithm/cxx14/move_backward.hpp @@ -0,0 +1,33 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_MOVE_BACKWARD_HPP +#define SPROUT_CXX14_ALGORITHM_MOVE_BACKWARD_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // 25.3.2 Move + // + template< + typename InputIterator, typename OutputIterator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + move_backward(InputIterator first, InputIterator last, OutputIterator result) { + while (first != last) { + *--result = sprout::move(*--first); + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_MOVE_BACKWARD_HPP diff --git a/sprout/algorithm/cxx14/partition.hpp b/sprout/algorithm/cxx14/partition.hpp new file mode 100644 index 00000000..578a0a53 --- /dev/null +++ b/sprout/algorithm/cxx14/partition.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_PARTITION_HPP +#define SPROUT_CXX14_ALGORITHM_PARTITION_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // 25.3.13 Partitions + // + template + inline SPROUT_CXX14_CONSTEXPR ForwardIterator + partition(ForwardIterator first, ForwardIterator last, Predicate pred) { + first = sprout::find_if_not(first, last, pred); + ForwardIterator it = sprout::find_if(first, last, pred); + while (it != last) { + sprout::iter_swap(first, it); + first = sprout::find_if_not(first, last, pred); + it = sprout::find_if(it, last, pred); + } + return first; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_PARTITION_HPP diff --git a/sprout/algorithm/cxx14/partition_copy.hpp b/sprout/algorithm/cxx14/partition_copy.hpp new file mode 100644 index 00000000..91d97729 --- /dev/null +++ b/sprout/algorithm/cxx14/partition_copy.hpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_PARTITION_COPY_HPP +#define SPROUT_CXX14_ALGORITHM_PARTITION_COPY_HPP + +#include +#include + +namespace sprout { + // + // 25.3.13 Partitions + // + template + inline SPROUT_CXX14_CONSTEXPR sprout::pair + partition_copy(InputIterator first, InputIterator last, OutputIterator1 out_true, OutputIterator2 out_false, Predicate pred); // !!! +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_PARTITION_COPY_HPP diff --git a/sprout/algorithm/cxx14/random_shuffle.hpp b/sprout/algorithm/cxx14/random_shuffle.hpp new file mode 100644 index 00000000..f9ccf155 --- /dev/null +++ b/sprout/algorithm/cxx14/random_shuffle.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_RANDOM_SHUFFLE_HPP +#define SPROUT_CXX14_ALGORITHM_RANDOM_SHUFFLE_HPP + +#include +#include + +namespace sprout { + // + // 25.3.12 Random shuffle + // + template + inline SPROUT_CXX14_CONSTEXPR void + random_shuffle(RandomAccessIterator first, RandomAccessIterator last, RandomNumberGenerator&& rand) { + if (first == last) { + return; + } + for (auto it = first + 1; it != last; ++it) { + sprout::iter_swap(it, first + rand(it - first + 1)); + } + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_RANDOM_SHUFFLE_HPP diff --git a/sprout/algorithm/cxx14/remove.hpp b/sprout/algorithm/cxx14/remove.hpp new file mode 100644 index 00000000..15889502 --- /dev/null +++ b/sprout/algorithm/cxx14/remove.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_REMOVE_HPP +#define SPROUT_CXX14_ALGORITHM_REMOVE_HPP + +#include +#include + +namespace sprout { + // + // 25.3.8 Remove + // + template + inline SPROUT_CXX14_CONSTEXPR ForwardIterator + remove(ForwardIterator first, ForwardIterator last, T const& value) { + ForwardIterator result = first; + for (; first != last; ++first) { + if (!(*first == value)) { + *result++ = sprout::move(*first); + } + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_REMOVE_HPP diff --git a/sprout/algorithm/cxx14/remove_copy.hpp b/sprout/algorithm/cxx14/remove_copy.hpp new file mode 100644 index 00000000..bef3e143 --- /dev/null +++ b/sprout/algorithm/cxx14/remove_copy.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_REMOVE_COPY_HPP +#define SPROUT_CXX14_ALGORITHM_REMOVE_COPY_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.8 Remove + // + template< + typename InputIterator, typename OutputIterator, typename T, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + remove_copy(InputIterator first, InputIterator last, OutputIterator result, T const& value) { + for (; first != last; ++first) { + if (!(*first == value)) { + *result++ = *first; + } + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_REMOVE_COPY_HPP diff --git a/sprout/algorithm/cxx14/remove_copy_if.hpp b/sprout/algorithm/cxx14/remove_copy_if.hpp new file mode 100644 index 00000000..88c881d7 --- /dev/null +++ b/sprout/algorithm/cxx14/remove_copy_if.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_REMOVE_COPY_IF_HPP +#define SPROUT_CXX14_ALGORITHM_REMOVE_COPY_IF_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.8 Remove + // + template< + typename InputIterator, typename OutputIterator, typename Predicate, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred) { + for (; first != last; ++first) { + if (!pred(*first)) { + *result++ = *first; + } + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_REMOVE_COPY_IF_HPP diff --git a/sprout/algorithm/cxx14/remove_if.hpp b/sprout/algorithm/cxx14/remove_if.hpp new file mode 100644 index 00000000..cca43844 --- /dev/null +++ b/sprout/algorithm/cxx14/remove_if.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_REMOVE_IF_HPP +#define SPROUT_CXX14_ALGORITHM_REMOVE_IF_HPP + +#include +#include + +namespace sprout { + // + // 25.3.8 Remove + // + template + inline SPROUT_CXX14_CONSTEXPR ForwardIterator + remove_if(ForwardIterator first, ForwardIterator last, Predicate pred) { + ForwardIterator result = first; + for (; first != last; ++first) { + if (!pred(*first)) { + *result++ = sprout::move(*first); + } + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_REMOVE_IF_HPP diff --git a/sprout/algorithm/cxx14/replace.hpp b/sprout/algorithm/cxx14/replace.hpp new file mode 100644 index 00000000..537aab24 --- /dev/null +++ b/sprout/algorithm/cxx14/replace.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_REPLACE_HPP +#define SPROUT_CXX14_ALGORITHM_REPLACE_HPP + +#include + +namespace sprout { + // + // 25.3.5 Replace + // + template + inline SPROUT_CXX14_CONSTEXPR void + replace(ForwardIterator first, ForwardIterator last, T const& old_value, T const& new_value) { + for (; first != last; ++first) { + if (*first == old_value) { + *first = new_value; + } + } + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_REPLACE_HPP diff --git a/sprout/algorithm/cxx14/replace_copy.hpp b/sprout/algorithm/cxx14/replace_copy.hpp new file mode 100644 index 00000000..4d4b0077 --- /dev/null +++ b/sprout/algorithm/cxx14/replace_copy.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_REPLACE_COPY_HPP +#define SPROUT_CXX14_ALGORITHM_REPLACE_COPY_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.5 Replace + // + template< + typename InputIterator, typename OutputIterator, typename T, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR void + replace_copy(InputIterator first, InputIterator last, OutputIterator result, T const& old_value, T const& new_value) { + for (; first != last; ++first) { + *result++ = (*first == old_value ? new_value : *first); + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_REPLACE_COPY_HPP diff --git a/sprout/algorithm/cxx14/replace_copy_if.hpp b/sprout/algorithm/cxx14/replace_copy_if.hpp new file mode 100644 index 00000000..4b25c438 --- /dev/null +++ b/sprout/algorithm/cxx14/replace_copy_if.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_REPLACE_COPY_IF_HPP +#define SPROUT_CXX14_ALGORITHM_REPLACE_COPY_IF_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.5 Replace + // + template< + typename InputIterator, typename OutputIterator, typename Predicate, typename T, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR void + replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, T const& new_value) { + for (; first != last; ++first) { + *result++ = (pred(*first) ? new_value : *first); + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_REPLACE_COPY_IF_HPP diff --git a/sprout/algorithm/cxx14/replace_if.hpp b/sprout/algorithm/cxx14/replace_if.hpp new file mode 100644 index 00000000..a2a80879 --- /dev/null +++ b/sprout/algorithm/cxx14/replace_if.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_REPLACE_IF_HPP +#define SPROUT_CXX14_ALGORITHM_REPLACE_IF_HPP + +#include + +namespace sprout { + // + // 25.3.5 Replace + // + template + inline SPROUT_CXX14_CONSTEXPR void + replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, T const& new_value) { + for (; first != last; ++first) { + if (pred(*first)) { + *first = new_value; + } + } + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_REPLACE_IF_HPP diff --git a/sprout/algorithm/cxx14/reverse.hpp b/sprout/algorithm/cxx14/reverse.hpp new file mode 100644 index 00000000..2801eb34 --- /dev/null +++ b/sprout/algorithm/cxx14/reverse.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_REVERSE_HPP +#define SPROUT_CXX14_ALGORITHM_REVERSE_HPP + +#include +#include + +namespace sprout { + // + // 25.3.10 Reverse + // + template + inline SPROUT_CXX14_CONSTEXPR void + reverse(BidirectionalIterator first, BidirectionalIterator last) { + for (; first != last && first != --last; ++first) { + sprout::iter_swap(first, last); + } + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_REVERSE_HPP diff --git a/sprout/algorithm/cxx14/reverse_copy.hpp b/sprout/algorithm/cxx14/reverse_copy.hpp new file mode 100644 index 00000000..a144d6c0 --- /dev/null +++ b/sprout/algorithm/cxx14/reverse_copy.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_REVERSE_COPY_HPP +#define SPROUT_CXX14_ALGORITHM_REVERSE_COPY_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.10 Reverse + // + template< + typename BidirectionalIterator, typename OutputIterator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result) { + while (first != last) { + *result++ = *--last; + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_REVERSE_COPY_HPP diff --git a/sprout/algorithm/cxx14/rotate.hpp b/sprout/algorithm/cxx14/rotate.hpp new file mode 100644 index 00000000..eb71e68f --- /dev/null +++ b/sprout/algorithm/cxx14/rotate.hpp @@ -0,0 +1,58 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_ROTATE_HPP +#define SPROUT_CXX14_ALGORITHM_ROTATE_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.11 Rotate + // + template + inline SPROUT_CXX14_CONSTEXPR ForwardIterator + rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last) { + if (first == middle) { + return last; + } else if (middle == last) { + return first; + } + ForwardIterator first2 = middle; + while (true) { + sprout::iter_swap(first, first2); + ++first; + if (++first2 == last) { + break; + } + if (first == middle) { + middle = first2; + } + } + ForwardIterator result = first; + if (first != middle) { + first2 = middle; + while (true) { + sprout::iter_swap(first, first2); + ++first; + if (++first2 == last) { + if (first == middle) { + break; + } + first2 = middle; + } else if (first == middle) { + middle = first2; + } + } + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_ROTATE_HPP diff --git a/sprout/algorithm/cxx14/rotate_copy.hpp b/sprout/algorithm/cxx14/rotate_copy.hpp new file mode 100644 index 00000000..2a9b300e --- /dev/null +++ b/sprout/algorithm/cxx14/rotate_copy.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_ROTATE_COPY_HPP +#define SPROUT_CXX14_ALGORITHM_ROTATE_COPY_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // 25.3.11 Rotate + // + template< + typename ForwardIterator, typename OutputIterator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result) { + return sprout::copy(first, middle, sprout::copy(middle, last, result)); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_ROTATE_COPY_HPP diff --git a/sprout/algorithm/cxx14/shuffle.hpp b/sprout/algorithm/cxx14/shuffle.hpp new file mode 100644 index 00000000..823a3879 --- /dev/null +++ b/sprout/algorithm/cxx14/shuffle.hpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_SHUFFLE_HPP +#define SPROUT_CXX14_ALGORITHM_SHUFFLE_HPP + +#include + +namespace sprout { + // + // 25.3.12 Random shuffle + // + template + inline SPROUT_CXX14_CONSTEXPR void + shuffle(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g); // !!! +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_SHUFFLE_HPP diff --git a/sprout/algorithm/cxx14/stable_partition.hpp b/sprout/algorithm/cxx14/stable_partition.hpp new file mode 100644 index 00000000..3c7bf00a --- /dev/null +++ b/sprout/algorithm/cxx14/stable_partition.hpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_STABLE_PARTITION_HPP +#define SPROUT_CXX14_ALGORITHM_STABLE_PARTITION_HPP + +#include + +namespace sprout { + // + // 25.3.13 Partitions + // + template + inline SPROUT_CXX14_CONSTEXPR BidirectionalIterator + stable_partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred); // !!! +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_STABLE_PARTITION_HPP diff --git a/sprout/algorithm/cxx14/swap_ranges.hpp b/sprout/algorithm/cxx14/swap_ranges.hpp new file mode 100644 index 00000000..dc2e3bdd --- /dev/null +++ b/sprout/algorithm/cxx14/swap_ranges.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_SWAP_RANGES_HPP +#define SPROUT_CXX14_ALGORITHM_SWAP_RANGES_HPP + +#include +#include + +namespace sprout { + // + // 25.3.3 swap + // + template + inline SPROUT_CXX14_CONSTEXPR ForwardIterator2 + swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2) { + while (first1 != last1) { + sprout::iter_swap(first1++, first2++); + } + return first2; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_SWAP_RANGES_HPP diff --git a/sprout/algorithm/cxx14/transform.hpp b/sprout/algorithm/cxx14/transform.hpp new file mode 100644 index 00000000..7a771439 --- /dev/null +++ b/sprout/algorithm/cxx14/transform.hpp @@ -0,0 +1,43 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_TRANSFORM_HPP +#define SPROUT_CXX14_ALGORITHM_TRANSFORM_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.4 Transform + // + template< + typename InputIterator, typename OutputIterator, typename UnaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op) { + while (first != last) { + *result++ = op(*first++); + } + return result; + } + template< + typename InputIterator1, typename InputIterator2, typename OutputIterator, typename BinaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryOperation op) { + while (first1 != last1) { + *result++ = op(*first1++, *first2++); + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_TRANSFORM_HPP diff --git a/sprout/algorithm/cxx14/unique.hpp b/sprout/algorithm/cxx14/unique.hpp new file mode 100644 index 00000000..bcdcb76c --- /dev/null +++ b/sprout/algorithm/cxx14/unique.hpp @@ -0,0 +1,55 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_UNIQUE_HPP +#define SPROUT_CXX14_ALGORITHM_UNIQUE_HPP + +#include +#include +#include + +namespace sprout { + // + // 25.3.9 Unique + // + template + inline SPROUT_CXX14_CONSTEXPR ForwardIterator + unique(ForwardIterator first, ForwardIterator last) { + if (first == last) { + return first; + } + ForwardIterator result = first; + typename std::iterator_traits::value_type value = sprout::move(*first++); + for (; first != last; ++first) { + if (!(value == *first)) { + *result++ = sprout::move(value); + value = sprout::move(*first); + } + } + *result++ = sprout::move(value); + return result; + } + template + inline SPROUT_CXX14_CONSTEXPR ForwardIterator + unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) { + if (first == last) { + return first; + } + ForwardIterator result = first; + typename std::iterator_traits::value_type value = sprout::move(*first++); + for (; first != last; ++first) { + if (!pred(value, *first)) { + *result++ = sprout::move(value); + value = sprout::move(*first); + } + } + *result++ = sprout::move(value); + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_UNIQUE_HPP diff --git a/sprout/algorithm/cxx14/unique_copy.hpp b/sprout/algorithm/cxx14/unique_copy.hpp new file mode 100644 index 00000000..0d62819e --- /dev/null +++ b/sprout/algorithm/cxx14/unique_copy.hpp @@ -0,0 +1,61 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_UNIQUE_COPY_HPP +#define SPROUT_CXX14_ALGORITHM_UNIQUE_COPY_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // 25.3.9 Unique + // + template< + typename InputIterator, typename OutputIterator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + unique_copy(InputIterator first, InputIterator last, OutputIterator result) { + if (first == last) { + return result; + } + typename std::iterator_traits::value_type value = *first++; + *result++ = value; + for (; first != last; ++first) { + if (!(value == *first)) { + value = *first; + *result++ = value; + } + } + return result; + } + + template< + typename InputIterator, typename OutputIterator, typename BinaryPredicate, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred) { + if (first == last) { + return result; + } + typename std::iterator_traits::value_type value = *first++; + *result++ = value; + for (; first != last; ++first) { + if (!pred(value, *first)) { + value = *first; + *result++ = value; + } + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_UNIQUE_COPY_HPP diff --git a/sprout/algorithm/fill.hpp b/sprout/algorithm/fill.hpp index b67982ff..c24b16d5 100644 --- a/sprout/algorithm/fill.hpp +++ b/sprout/algorithm/fill.hpp @@ -9,21 +9,8 @@ #define SPROUT_ALGORITHM_FILL_HPP #include - -namespace sprout { - // - // 25.3.6 Fill - // - template - inline SPROUT_CXX14_CONSTEXPR void - fill(ForwardIterator first, ForwardIterator last, T const& value) { - while (first != last) { - *first++ = value; - } - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_FILL_HPP diff --git a/sprout/algorithm/fill_n.hpp b/sprout/algorithm/fill_n.hpp index 1e64c89d..0b65e444 100644 --- a/sprout/algorithm/fill_n.hpp +++ b/sprout/algorithm/fill_n.hpp @@ -9,27 +9,8 @@ #define SPROUT_ALGORITHM_FILL_N_HPP #include -#include -#include - -namespace sprout { - // - // 25.3.6 Fill - // - template< - typename OutputIterator, typename Size, typename T, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - fill_n(OutputIterator first, Size n, T const& value) { - while (n-- > 0) { - *first++ = value; - } - return first; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_FILL_N_HPP diff --git a/sprout/algorithm/generate.hpp b/sprout/algorithm/generate.hpp index d579ec00..a44ee49e 100644 --- a/sprout/algorithm/generate.hpp +++ b/sprout/algorithm/generate.hpp @@ -9,21 +9,8 @@ #define SPROUT_ALGORITHM_GENERATE_HPP #include - -namespace sprout { - // - // 25.3.7 Generate - // - template - inline SPROUT_CXX14_CONSTEXPR void - generate(ForwardIterator first, ForwardIterator last, Generator gen) { - while (first != last) { - *first++ = gen(); - } - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_GENERATE_HPP diff --git a/sprout/algorithm/generate_n.hpp b/sprout/algorithm/generate_n.hpp index e4788088..716cae0f 100644 --- a/sprout/algorithm/generate_n.hpp +++ b/sprout/algorithm/generate_n.hpp @@ -9,25 +9,8 @@ #define SPROUT_ALGORITHM_GENERATE_N_HPP #include - -namespace sprout { - // - // 25.3.7 Generate - // - template< - typename OutputIterator, typename Size, typename Generator, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - generate_n(OutputIterator first, Size n, Generator gen) { - while (n-- > 0) { - *first++ = gen(); - } - return first; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_GENERATE_N_HPP diff --git a/sprout/algorithm/iter_swap.hpp b/sprout/algorithm/iter_swap.hpp index e0db022d..5d76c552 100644 --- a/sprout/algorithm/iter_swap.hpp +++ b/sprout/algorithm/iter_swap.hpp @@ -9,17 +9,6 @@ #define SPROUT_ALGORITHM_ITER_SWAP_HPP #include -#include - -namespace sprout { - // - // 25.3.3 swap - // - template - inline SPROUT_CXX14_CONSTEXPR void - iter_swap(ForwardIterator1 a, ForwardIterator2 b) { - sprout::swap(*a, *b); - } -} // namespace sprout +#include #endif // #ifndef SPROUT_ALGORITHM_ITER_SWAP_HPP diff --git a/sprout/algorithm/modifying.hpp b/sprout/algorithm/modifying.hpp index 8ecc6681..62621ada 100644 --- a/sprout/algorithm/modifying.hpp +++ b/sprout/algorithm/modifying.hpp @@ -9,72 +9,8 @@ #define SPROUT_ALGORITHM_MODIFYIING_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 -#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_MODIFYIING_HPP diff --git a/sprout/algorithm/move.hpp b/sprout/algorithm/move.hpp index 09eee472..d9d59c22 100644 --- a/sprout/algorithm/move.hpp +++ b/sprout/algorithm/move.hpp @@ -9,25 +9,6 @@ #define SPROUT_ALGORITHM_MOVE_HPP #include -#include -#include -#include - -namespace sprout { - // - // 25.3.2 Move - // - template< - typename InputIterator, typename OutputIterator, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - move(InputIterator first, InputIterator last, OutputIterator result) { - while (first != last) { - *result++ = sprout::move(*first++); - } - return result; - } -} // namespace sprout +#include #endif // #ifndef SPROUT_ALGORITHM_MOVE_HPP diff --git a/sprout/algorithm/move_backward.hpp b/sprout/algorithm/move_backward.hpp index 96d23313..d498118c 100644 --- a/sprout/algorithm/move_backward.hpp +++ b/sprout/algorithm/move_backward.hpp @@ -9,25 +9,6 @@ #define SPROUT_ALGORITHM_MOVE_BACKWARD_HPP #include -#include -#include -#include - -namespace sprout { - // - // 25.3.2 Move - // - template< - typename InputIterator, typename OutputIterator, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - move_backward(InputIterator first, InputIterator last, OutputIterator result) { - while (first != last) { - *--result = sprout::move(*--first); - } - return result; - } -} // namespace sprout +#include #endif // #ifndef SPROUT_ALGORITHM_MOVE_BACKWARD_HPP diff --git a/sprout/algorithm/partition.hpp b/sprout/algorithm/partition.hpp index 3275454d..2422f345 100644 --- a/sprout/algorithm/partition.hpp +++ b/sprout/algorithm/partition.hpp @@ -9,29 +9,8 @@ #define SPROUT_ALGORITHM_PARTITION_HPP #include -#include -#include -#include - -namespace sprout { - // - // 25.3.13 Partitions - // - template - inline SPROUT_CXX14_CONSTEXPR ForwardIterator - partition(ForwardIterator first, ForwardIterator last, Predicate pred) { - first = sprout::find_if_not(first, last, pred); - ForwardIterator it = sprout::find_if(first, last, pred); - while (it != last) { - sprout::iter_swap(first, it); - first = sprout::find_if_not(first, last, pred); - it = sprout::find_if(it, last, pred); - } - return first; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_PARTITION_HPP diff --git a/sprout/algorithm/partition_copy.hpp b/sprout/algorithm/partition_copy.hpp index 0a89b5a7..5498b4ac 100644 --- a/sprout/algorithm/partition_copy.hpp +++ b/sprout/algorithm/partition_copy.hpp @@ -9,18 +9,8 @@ #define SPROUT_ALGORITHM_PARTITION_COPY_HPP #include -#include - -namespace sprout { - // - // 25.3.13 Partitions - // - template - inline SPROUT_CXX14_CONSTEXPR sprout::pair - partition_copy(InputIterator first, InputIterator last, OutputIterator1 out_true, OutputIterator2 out_false, Predicate pred); // !!! -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_PARTITION_COPY_HPP diff --git a/sprout/algorithm/random_shuffle.hpp b/sprout/algorithm/random_shuffle.hpp index 7c9ad98e..773eca27 100644 --- a/sprout/algorithm/random_shuffle.hpp +++ b/sprout/algorithm/random_shuffle.hpp @@ -9,22 +9,6 @@ #define SPROUT_ALGORITHM_RANDOM_SHUFFLE_HPP #include -#include - -namespace sprout { - // - // 25.3.12 Random shuffle - // - template - inline SPROUT_CXX14_CONSTEXPR void - random_shuffle(RandomAccessIterator first, RandomAccessIterator last, RandomNumberGenerator&& rand) { - if (first == last) { - return; - } - for (auto it = first + 1; it != last; ++it) { - sprout::iter_swap(it, first + rand(it - first + 1)); - } - } -} // namespace sprout +#include #endif // #ifndef SPROUT_ALGORITHM_RANDOM_SHUFFLE_HPP diff --git a/sprout/algorithm/remove.hpp b/sprout/algorithm/remove.hpp index 48e5c884..01b74433 100644 --- a/sprout/algorithm/remove.hpp +++ b/sprout/algorithm/remove.hpp @@ -9,26 +9,8 @@ #define SPROUT_ALGORITHM_REMOVE_HPP #include -#include - -namespace sprout { - // - // 25.3.8 Remove - // - template - inline SPROUT_CXX14_CONSTEXPR ForwardIterator - remove(ForwardIterator first, ForwardIterator last, T const& value) { - ForwardIterator result = first; - for (; first != last; ++first) { - if (!(*first == value)) { - *result++ = sprout::move(*first); - } - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_REMOVE_HPP diff --git a/sprout/algorithm/remove_copy.hpp b/sprout/algorithm/remove_copy.hpp index cc2e793c..6979fec6 100644 --- a/sprout/algorithm/remove_copy.hpp +++ b/sprout/algorithm/remove_copy.hpp @@ -9,29 +9,8 @@ #define SPROUT_ALGORITHM_REMOVE_COPY_HPP #include -#include -#include - -namespace sprout { - // - // 25.3.8 Remove - // - template< - typename InputIterator, typename OutputIterator, typename T, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - remove_copy(InputIterator first, InputIterator last, OutputIterator result, T const& value) { - for (; first != last; ++first) { - if (!(*first == value)) { - *result++ = *first; - } - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_REMOVE_COPY_HPP diff --git a/sprout/algorithm/remove_copy_if.hpp b/sprout/algorithm/remove_copy_if.hpp index 2d8829fb..8e12a390 100644 --- a/sprout/algorithm/remove_copy_if.hpp +++ b/sprout/algorithm/remove_copy_if.hpp @@ -9,29 +9,8 @@ #define SPROUT_ALGORITHM_REMOVE_COPY_IF_HPP #include -#include -#include - -namespace sprout { - // - // 25.3.8 Remove - // - template< - typename InputIterator, typename OutputIterator, typename Predicate, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred) { - for (; first != last; ++first) { - if (!pred(*first)) { - *result++ = *first; - } - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_REMOVE_COPY_IF_HPP diff --git a/sprout/algorithm/remove_if.hpp b/sprout/algorithm/remove_if.hpp index e7570548..f71cbe51 100644 --- a/sprout/algorithm/remove_if.hpp +++ b/sprout/algorithm/remove_if.hpp @@ -9,26 +9,8 @@ #define SPROUT_ALGORITHM_REMOVE_IF_HPP #include -#include - -namespace sprout { - // - // 25.3.8 Remove - // - template - inline SPROUT_CXX14_CONSTEXPR ForwardIterator - remove_if(ForwardIterator first, ForwardIterator last, Predicate pred) { - ForwardIterator result = first; - for (; first != last; ++first) { - if (!pred(*first)) { - *result++ = sprout::move(*first); - } - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_REMOVE_IF_HPP diff --git a/sprout/algorithm/replace.hpp b/sprout/algorithm/replace.hpp index b918a9d1..242507d3 100644 --- a/sprout/algorithm/replace.hpp +++ b/sprout/algorithm/replace.hpp @@ -9,23 +9,8 @@ #define SPROUT_ALGORITHM_REPLACE_HPP #include - -namespace sprout { - // - // 25.3.5 Replace - // - template - inline SPROUT_CXX14_CONSTEXPR void - replace(ForwardIterator first, ForwardIterator last, T const& old_value, T const& new_value) { - for (; first != last; ++first) { - if (*first == old_value) { - *first = new_value; - } - } - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_REPLACE_HPP diff --git a/sprout/algorithm/replace_copy.hpp b/sprout/algorithm/replace_copy.hpp index b45c6751..c12ac3f6 100644 --- a/sprout/algorithm/replace_copy.hpp +++ b/sprout/algorithm/replace_copy.hpp @@ -9,27 +9,8 @@ #define SPROUT_ALGORITHM_REPLACE_COPY_HPP #include -#include -#include - -namespace sprout { - // - // 25.3.5 Replace - // - template< - typename InputIterator, typename OutputIterator, typename T, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR void - replace_copy(InputIterator first, InputIterator last, OutputIterator result, T const& old_value, T const& new_value) { - for (; first != last; ++first) { - *result++ = (*first == old_value ? new_value : *first); - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_REPLACE_COPY_HPP diff --git a/sprout/algorithm/replace_copy_if.hpp b/sprout/algorithm/replace_copy_if.hpp index be0332dd..8b8ed6ef 100644 --- a/sprout/algorithm/replace_copy_if.hpp +++ b/sprout/algorithm/replace_copy_if.hpp @@ -9,27 +9,8 @@ #define SPROUT_ALGORITHM_REPLACE_COPY_IF_HPP #include -#include -#include - -namespace sprout { - // - // 25.3.5 Replace - // - template< - typename InputIterator, typename OutputIterator, typename Predicate, typename T, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR void - replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, T const& new_value) { - for (; first != last; ++first) { - *result++ = (pred(*first) ? new_value : *first); - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_REPLACE_COPY_IF_HPP diff --git a/sprout/algorithm/replace_if.hpp b/sprout/algorithm/replace_if.hpp index 53e772c5..716dc1e7 100644 --- a/sprout/algorithm/replace_if.hpp +++ b/sprout/algorithm/replace_if.hpp @@ -9,23 +9,8 @@ #define SPROUT_ALGORITHM_REPLACE_IF_HPP #include - -namespace sprout { - // - // 25.3.5 Replace - // - template - inline SPROUT_CXX14_CONSTEXPR void - replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, T const& new_value) { - for (; first != last; ++first) { - if (pred(*first)) { - *first = new_value; - } - } - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_REPLACE_IF_HPP diff --git a/sprout/algorithm/reverse.hpp b/sprout/algorithm/reverse.hpp index 899731aa..df763d8d 100644 --- a/sprout/algorithm/reverse.hpp +++ b/sprout/algorithm/reverse.hpp @@ -9,22 +9,8 @@ #define SPROUT_ALGORITHM_REVERSE_HPP #include -#include - -namespace sprout { - // - // 25.3.10 Reverse - // - template - inline SPROUT_CXX14_CONSTEXPR void - reverse(BidirectionalIterator first, BidirectionalIterator last) { - for (; first != last && first != --last; ++first) { - sprout::iter_swap(first, last); - } - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_REVERSE_HPP diff --git a/sprout/algorithm/reverse_copy.hpp b/sprout/algorithm/reverse_copy.hpp index 4e29908f..b8cb885b 100644 --- a/sprout/algorithm/reverse_copy.hpp +++ b/sprout/algorithm/reverse_copy.hpp @@ -9,27 +9,8 @@ #define SPROUT_ALGORITHM_REVERSE_COPY_HPP #include -#include -#include - -namespace sprout { - // - // 25.3.10 Reverse - // - template< - typename BidirectionalIterator, typename OutputIterator, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result) { - while (first != last) { - *result++ = *--last; - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_REVERSE_COPY_HPP diff --git a/sprout/algorithm/rotate.hpp b/sprout/algorithm/rotate.hpp index 4023e05f..34248513 100644 --- a/sprout/algorithm/rotate.hpp +++ b/sprout/algorithm/rotate.hpp @@ -8,54 +8,9 @@ #ifndef SPROUT_ALGORITHM_ROTATE_HPP #define SPROUT_ALGORITHM_ROTATE_HPP -#include #include -#include - -namespace sprout { - // - // 25.3.11 Rotate - // - template - inline SPROUT_CXX14_CONSTEXPR ForwardIterator - rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last) { - if (first == middle) { - return last; - } else if (middle == last) { - return first; - } - ForwardIterator first2 = middle; - while (true) { - sprout::iter_swap(first, first2); - ++first; - if (++first2 == last) { - break; - } - if (first == middle) { - middle = first2; - } - } - ForwardIterator result = first; - if (first != middle) { - first2 = middle; - while (true) { - sprout::iter_swap(first, first2); - ++first; - if (++first2 == last) { - if (first == middle) { - break; - } - first2 = middle; - } else if (first == middle) { - middle = first2; - } - } - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_ROTATE_HPP diff --git a/sprout/algorithm/rotate_copy.hpp b/sprout/algorithm/rotate_copy.hpp index 6adaab1b..2ea3a783 100644 --- a/sprout/algorithm/rotate_copy.hpp +++ b/sprout/algorithm/rotate_copy.hpp @@ -9,25 +9,8 @@ #define SPROUT_ALGORITHM_ROTATE_COPY_HPP #include -#include -#include -#include - -namespace sprout { - // - // 25.3.11 Rotate - // - template< - typename ForwardIterator, typename OutputIterator, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result) { - return sprout::copy(first, middle, sprout::copy(middle, last, result)); - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_ROTATE_COPY_HPP diff --git a/sprout/algorithm/shuffle.hpp b/sprout/algorithm/shuffle.hpp index 41bb628e..99d8cf0d 100644 --- a/sprout/algorithm/shuffle.hpp +++ b/sprout/algorithm/shuffle.hpp @@ -9,17 +9,8 @@ #define SPROUT_ALGORITHM_SHUFFLE_HPP #include - -namespace sprout { - // - // 25.3.12 Random shuffle - // - template - inline SPROUT_CXX14_CONSTEXPR void - shuffle(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g); // !!! -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_SHUFFLE_HPP diff --git a/sprout/algorithm/stable_partition.hpp b/sprout/algorithm/stable_partition.hpp index b2a03b7e..5bc134f2 100644 --- a/sprout/algorithm/stable_partition.hpp +++ b/sprout/algorithm/stable_partition.hpp @@ -9,18 +9,8 @@ #define SPROUT_ALGORITHM_STABLE_PARTITION_HPP #include - - -namespace sprout { - // - // 25.3.13 Partitions - // - template - inline SPROUT_CXX14_CONSTEXPR BidirectionalIterator - stable_partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred); // !!! -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_STABLE_PARTITION_HPP diff --git a/sprout/algorithm/swap_ranges.hpp b/sprout/algorithm/swap_ranges.hpp index e981401d..c3517839 100644 --- a/sprout/algorithm/swap_ranges.hpp +++ b/sprout/algorithm/swap_ranges.hpp @@ -9,20 +9,6 @@ #define SPROUT_ALGORITHM_SWAP_RANGES_HPP #include -#include - -namespace sprout { - // - // 25.3.3 swap - // - template - inline SPROUT_CXX14_CONSTEXPR ForwardIterator2 - swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2) { - while (first1 != last1) { - sprout::iter_swap(first1++, first2++); - } - return first2; - } -} // namespace sprout +#include #endif // #ifndef SPROUT_ALGORITHM_SWAP_RANGES_HPP diff --git a/sprout/algorithm/transform.hpp b/sprout/algorithm/transform.hpp index 3ddd1298..8bd0c6ee 100644 --- a/sprout/algorithm/transform.hpp +++ b/sprout/algorithm/transform.hpp @@ -9,38 +9,8 @@ #define SPROUT_ALGORITHM_TRANSFORM_HPP #include -#include -#include - -namespace sprout { - // - // 25.3.4 Transform - // - template< - typename InputIterator, typename OutputIterator, typename UnaryOperation, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op) { - while (first != last) { - *result++ = op(*first++); - } - return result; - } - template< - typename InputIterator1, typename InputIterator2, typename OutputIterator, typename BinaryOperation, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryOperation op) { - while (first1 != last1) { - *result++ = op(*first1++, *first2++); - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_TRANSFORM_HPP diff --git a/sprout/algorithm/unique.hpp b/sprout/algorithm/unique.hpp index 38c88ec9..f9ba316a 100644 --- a/sprout/algorithm/unique.hpp +++ b/sprout/algorithm/unique.hpp @@ -8,51 +8,9 @@ #ifndef SPROUT_ALGORITHM_UNIQUE_HPP #define SPROUT_ALGORITHM_UNIQUE_HPP -#include #include -#include - -namespace sprout { - // - // 25.3.9 Unique - // - template - inline SPROUT_CXX14_CONSTEXPR ForwardIterator - unique(ForwardIterator first, ForwardIterator last) { - if (first == last) { - return first; - } - ForwardIterator result = first; - typename std::iterator_traits::value_type value = sprout::move(*first++); - for (; first != last; ++first) { - if (!(value == *first)) { - *result++ = sprout::move(value); - value = sprout::move(*first); - } - } - *result++ = sprout::move(value); - return result; - } - template - inline SPROUT_CXX14_CONSTEXPR ForwardIterator - unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) { - if (first == last) { - return first; - } - ForwardIterator result = first; - typename std::iterator_traits::value_type value = sprout::move(*first++); - for (; first != last; ++first) { - if (!pred(value, *first)) { - *result++ = sprout::move(value); - value = sprout::move(*first); - } - } - *result++ = sprout::move(value); - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_UNIQUE_HPP diff --git a/sprout/algorithm/unique_copy.hpp b/sprout/algorithm/unique_copy.hpp index 28282ec7..2e67b160 100644 --- a/sprout/algorithm/unique_copy.hpp +++ b/sprout/algorithm/unique_copy.hpp @@ -8,57 +8,9 @@ #ifndef SPROUT_ALGORITHM_UNIQUE_COPY_HPP #define SPROUT_ALGORITHM_UNIQUE_COPY_HPP -#include #include -#include -#include - -namespace sprout { - // - // 25.3.9 Unique - // - template< - typename InputIterator, typename OutputIterator, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - unique_copy(InputIterator first, InputIterator last, OutputIterator result) { - if (first == last) { - return result; - } - typename std::iterator_traits::value_type value = *first++; - *result++ = value; - for (; first != last; ++first) { - if (!(value == *first)) { - value = *first; - *result++ = value; - } - } - return result; - } - - template< - typename InputIterator, typename OutputIterator, typename BinaryPredicate, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CXX14_CONSTEXPR OutputIterator - unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred) { - if (first == last) { - return result; - } - typename std::iterator_traits::value_type value = *first++; - *result++ = value; - for (; first != last; ++first) { - if (!pred(value, *first)) { - value = *first; - *result++ = value; - } - } - return result; - } -} // namespace sprout - #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_UNIQUE_COPY_HPP diff --git a/sprout/array/array.hpp b/sprout/array/array.hpp index 67935313..9b310358 100644 --- a/sprout/array/array.hpp +++ b/sprout/array/array.hpp @@ -17,10 +17,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION # include diff --git a/sprout/bitset/bitset.hpp b/sprout/bitset/bitset.hpp index 7efee301..02ba0c4c 100644 --- a/sprout/bitset/bitset.hpp +++ b/sprout/bitset/bitset.hpp @@ -10,9 +10,7 @@ #include #include -#include #include -#include #include #include #include @@ -25,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -322,7 +321,7 @@ namespace sprout { } w_[wshift] = w_[0] << offset; } - std::fill(w_ + 0, w_ + wshift, static_cast(0)); + sprout::fill(w_ + 0, w_ + wshift, static_cast(0)); } } SPROUT_CONSTEXPR base_bitset @@ -351,7 +350,7 @@ namespace sprout { } w_[limit] = w_[N-1] >> offset; } - std::fill(w_ + limit + 1, w_ + N, static_cast(0)); + sprout::fill(w_ + limit + 1, w_ + N, static_cast(0)); } } SPROUT_CONSTEXPR base_bitset @@ -392,7 +391,7 @@ namespace sprout { } SPROUT_CXX14_CONSTEXPR void do_reset() SPROUT_NOEXCEPT { - std::memset(w_, 0, N * sprout::detail::sizeof_::value); + sprout::fill(w_ + 0, w_ + N, static_cast(0)); } SPROUT_CONSTEXPR bool diff --git a/sprout/functional/bind/bind.hpp b/sprout/functional/bind/bind.hpp index ca4fb640..df1f6205 100644 --- a/sprout/functional/bind/bind.hpp +++ b/sprout/functional/bind/bind.hpp @@ -394,12 +394,12 @@ namespace sprout { -> decltype( sprout::detail::get_bound_helper::get_bound< sprout::detail::bound_position::type, ArgSize>::value - >(std::forward(bound_args)) + >(sprout::forward(bound_args)) ) { return sprout::detail::get_bound_helper::get_bound< sprout::detail::bound_position::type, ArgSize>::value - >(std::forward(bound_args)); + >(sprout::forward(bound_args)); } } // namespace detail diff --git a/sprout/range/range_container.hpp b/sprout/range/range_container.hpp index c21631c8..b4de299b 100644 --- a/sprout/range/range_container.hpp +++ b/sprout/range/range_container.hpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include namespace sprout { namespace range { @@ -95,8 +97,8 @@ namespace sprout { } template SPROUT_CXX14_CONSTEXPR range_container& operator=(range_container&& rhs) { - first_ = std::move(rhs.first_); - last_ = std::move(rhs.last_); + first_ = sprout::move(rhs.first_); + last_ = sprout::move(rhs.last_); return *this; } }; diff --git a/sprout/string/char_traits.hpp b/sprout/string/char_traits.hpp index 18da0e67..623b44c4 100644 --- a/sprout/string/char_traits.hpp +++ b/sprout/string/char_traits.hpp @@ -11,15 +11,14 @@ #include #include #include -#include #include #include #include #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/sprout/string/string.hpp b/sprout/string/string.hpp index c7c43e80..a821181e 100644 --- a/sprout/string/string.hpp +++ b/sprout/string/string.hpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sprout/sub_array/sub_array.hpp b/sprout/sub_array/sub_array.hpp index ac998241..e4d561b9 100644 --- a/sprout/sub_array/sub_array.hpp +++ b/sprout/sub_array/sub_array.hpp @@ -8,7 +8,6 @@ #ifndef SPROUT_SUB_ARRAY_SUB_ARRAY_HPP #define SPROUT_SUB_ARRAY_SUB_ARRAY_HPP -#include #include #include #include @@ -17,7 +16,9 @@ #include #include #include +#include #include +#include namespace sprout { namespace detail { @@ -244,7 +245,7 @@ namespace sprout { {} SPROUT_CXX14_CONSTEXPR void fill(const_reference value) { - std::fill_n(begin(), size(), value); + sprout::fill_n(begin(), size(), value); } template SPROUT_CXX14_CONSTEXPR void swap(sub_array& other) @@ -329,9 +330,9 @@ namespace sprout { } template SPROUT_CXX14_CONSTEXPR sub_array& operator=(sub_array&& rhs) { - array_ = std::move(rhs.array_); - to_first_ = std::move(rhs.to_first_); - to_last_ = std::move(rhs.to_last_); + array_ = sprout::move(rhs.array_); + to_first_ = sprout::move(rhs.to_first_); + to_last_ = sprout::move(rhs.to_last_); return *this; } SPROUT_CXX14_CONSTEXPR pointer c_array() { diff --git a/sprout/utility/string_ref/io.hpp b/sprout/utility/string_ref/io.hpp index b04b6c22..dec060e5 100644 --- a/sprout/utility/string_ref/io.hpp +++ b/sprout/utility/string_ref/io.hpp @@ -9,9 +9,9 @@ #define SPROUT_UTILITY_STRING_IO_HPP #include -#include #include #include +#include #include namespace sprout { @@ -21,7 +21,7 @@ namespace sprout { template inline std::basic_ostream& operator<<(std::basic_ostream& lhs, sprout::basic_string_ref const& rhs) { - std::copy(rhs.begin(), rhs.end(), std::ostreambuf_iterator(lhs)); + sprout::copy(rhs.begin(), rhs.end(), std::ostreambuf_iterator(lhs)); return lhs; } } // namespace sprout diff --git a/sprout/uuid/io.hpp b/sprout/uuid/io.hpp index d74232a1..bfc9eccd 100644 --- a/sprout/uuid/io.hpp +++ b/sprout/uuid/io.hpp @@ -9,13 +9,14 @@ #define SPROUT_UUID_IO_HPP #include -#include #include #include #include #include #include #include +#include +#include #include #include #include @@ -45,7 +46,7 @@ namespace sprout { for (sprout::uuids::uuid::size_type i = 0, last = rhs.size(); i < last && lhs; ++i) { lhs >> c; c = ctype.toupper(c); - char_type const* f = std::find(xdigits, xdigits_end, c); + char_type const* f = sprout::find(xdigits, xdigits_end, c); if (f == xdigits_end) { lhs.setstate(std::ios_base::failbit); break; @@ -53,7 +54,7 @@ namespace sprout { sprout::uuids::uuid::value_type byte = static_cast(std::distance(&xdigits[0], f)); lhs >> c; c = ctype.toupper(c); - f = std::find(xdigits, xdigits_end, c); + f = sprout::find(xdigits, xdigits_end, c); if (f == xdigits_end) { lhs.setstate(std::ios_base::failbit); break; @@ -72,7 +73,7 @@ namespace sprout { } } if (lhs) { - std::copy(data, data + 16, rhs.begin()); + sprout::copy(data, data + 16, rhs.begin()); } } return lhs; diff --git a/sprout/uuid/uuid.hpp b/sprout/uuid/uuid.hpp index 399db609..0e065d04 100644 --- a/sprout/uuid/uuid.hpp +++ b/sprout/uuid/uuid.hpp @@ -9,7 +9,6 @@ #define SPROUT_UUID_UUID_HPP #include -#include #include #include #include @@ -18,6 +17,8 @@ #include #include #include +#include +#include #if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION # include #endif @@ -82,10 +83,10 @@ namespace sprout { value_type elems[static_size]; public: SPROUT_CXX14_CONSTEXPR void fill(const_reference value) { - std::fill_n(begin(), size(), value); + sprout::fill_n(begin(), size(), value); } SPROUT_CXX14_CONSTEXPR void swap(uuid& other) SPROUT_NOEXCEPT { - std::swap_ranges(other.begin(), other.end(), begin()); + sprout::swap_ranges(other.begin(), other.end(), begin()); } // iterators: #if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION