add new directory sprout/algorithm/cxx14/

This commit is contained in:
bolero-MURAKAMI 2013-10-31 18:57:41 +09:00
parent 39d60a514f
commit 040278bd11
76 changed files with 1165 additions and 761 deletions

View file

@ -9,27 +9,8 @@
#define SPROUT_ALGORITHM_COPY_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.1 Copy
//
template<
typename InputIterator, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/fixed/copy.hpp>
#include <sprout/algorithm/fit/copy.hpp>
#include <sprout/algorithm/cxx14/copy.hpp>
#endif // #ifndef SPROUT_ALGORITHM_COPY_HPP

View file

@ -9,27 +9,8 @@
#define SPROUT_ALGORITHM_COPY_BACKWARD_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.1 Copy
//
template<
typename BidirectionalIterator1, typename BidirectionalIterator2,
typename sprout::enabler_if<sprout::is_iterator_outputable<BidirectionalIterator2>::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 <sprout/algorithm/fixed/copy_backward.hpp>
#include <sprout/algorithm/fit/copy_backward.hpp>
#include <sprout/algorithm/cxx14/copy_backward.hpp>
#endif // #ifndef SPROUT_ALGORITHM_COPY_BACKWARD_HPP

View file

@ -9,29 +9,8 @@
#define SPROUT_ALGORITHM_COPY_IF_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.1 Copy
//
template<
typename InputIterator, typename OutputIterator, typename Predicate,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/fixed/copy_if.hpp>
#include <sprout/algorithm/fit/copy_if.hpp>
#include <sprout/algorithm/cxx14/copy_if.hpp>
#endif // #ifndef SPROUT_ALGORITHM_COPY_IF_HPP

View file

@ -9,27 +9,8 @@
#define SPROUT_ALGORITHM_COPY_N_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.1 Copy
//
template<
typename InputIterator, typename Size, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/fixed/copy_n.hpp>
#include <sprout/algorithm/fit/copy_n.hpp>
#include <sprout/algorithm/cxx14/copy_n.hpp>
#endif // #ifndef SPROUT_ALGORITHM_COPY_N_HPP

View file

@ -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 <sprout/config.hpp>
#include <sprout/algorithm/cxx14/copy.hpp>
#include <sprout/algorithm/cxx14/copy_n.hpp>
#include <sprout/algorithm/cxx14/copy_if.hpp>
#include <sprout/algorithm/cxx14/copy_backward.hpp>
#include <sprout/algorithm/cxx14/move.hpp>
#include <sprout/algorithm/cxx14/move_backward.hpp>
#include <sprout/algorithm/cxx14/swap_ranges.hpp>
#include <sprout/algorithm/cxx14/iter_swap.hpp>
#include <sprout/algorithm/cxx14/transform.hpp>
#include <sprout/algorithm/cxx14/replace.hpp>
#include <sprout/algorithm/cxx14/replace_if.hpp>
#include <sprout/algorithm/cxx14/replace_copy.hpp>
#include <sprout/algorithm/cxx14/replace_copy_if.hpp>
#include <sprout/algorithm/cxx14/fill.hpp>
#include <sprout/algorithm/cxx14/fill_n.hpp>
#include <sprout/algorithm/cxx14/generate.hpp>
#include <sprout/algorithm/cxx14/generate_n.hpp>
#include <sprout/algorithm/cxx14/remove.hpp>
#include <sprout/algorithm/cxx14/remove_if.hpp>
#include <sprout/algorithm/cxx14/remove_copy.hpp>
#include <sprout/algorithm/cxx14/remove_copy_if.hpp>
#include <sprout/algorithm/cxx14/unique.hpp>
#include <sprout/algorithm/cxx14/unique_copy.hpp>
#include <sprout/algorithm/cxx14/reverse.hpp>
#include <sprout/algorithm/cxx14/reverse_copy.hpp>
#include <sprout/algorithm/cxx14/rotate.hpp>
#include <sprout/algorithm/cxx14/rotate_copy.hpp>
#include <sprout/algorithm/cxx14/random_shuffle.hpp>
#include <sprout/algorithm/cxx14/shuffle.hpp>
#include <sprout/algorithm/cxx14/partition.hpp>
#include <sprout/algorithm/cxx14/stable_partition.hpp>
#include <sprout/algorithm/cxx14/partition_copy.hpp>
#endif // #ifndef SPROUT_ALGORITHM_CXX14_HPP

View file

@ -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 <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.1 Copy
//
template<
typename InputIterator, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.1 Copy
//
template<
typename BidirectionalIterator1, typename BidirectionalIterator2,
typename sprout::enabler_if<sprout::is_iterator_outputable<BidirectionalIterator2>::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

View file

@ -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 <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.1 Copy
//
template<
typename InputIterator, typename OutputIterator, typename Predicate,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.1 Copy
//
template<
typename InputIterator, typename Size, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <sprout/config.hpp>
namespace sprout {
//
// 25.3.6 Fill
//
template<typename ForwardIterator, typename T>
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

View file

@ -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 <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.6 Fill
//
template<
typename OutputIterator, typename Size, typename T,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <sprout/config.hpp>
namespace sprout {
//
// 25.3.7 Generate
//
template<typename ForwardIterator, typename Generator>
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

View file

@ -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 <sprout/config.hpp>
namespace sprout {
//
// 25.3.7 Generate
//
template<
typename OutputIterator, typename Size, typename Generator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <sprout/config.hpp>
#include <sprout/utility/swap.hpp>
namespace sprout {
//
// 25.3.3 swap
//
template<typename ForwardIterator1, typename ForwardIterator2>
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

View file

@ -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 <sprout/config.hpp>
#include <sprout/type_traits/enabler_if.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
//
// 25.3.2 Move
//
template<
typename InputIterator, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <sprout/config.hpp>
#include <sprout/type_traits/enabler_if.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
//
// 25.3.2 Move
//
template<
typename InputIterator, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <sprout/config.hpp>
#include <sprout/algorithm/find_if.hpp>
#include <sprout/algorithm/find_if_not.hpp>
#include <sprout/algorithm/cxx14/iter_swap.hpp>
namespace sprout {
//
// 25.3.13 Partitions
//
template<typename ForwardIterator, typename Predicate>
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

View file

@ -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 <sprout/config.hpp>
#include <sprout/utility/pair.hpp>
namespace sprout {
//
// 25.3.13 Partitions
//
template<typename InputIterator, typename OutputIterator1, typename OutputIterator2, typename Predicate>
inline SPROUT_CXX14_CONSTEXPR sprout::pair<OutputIterator1, OutputIterator2>
partition_copy(InputIterator first, InputIterator last, OutputIterator1 out_true, OutputIterator2 out_false, Predicate pred); // !!!
} // namespace sprout
#endif // #ifndef SPROUT_CXX14_ALGORITHM_PARTITION_COPY_HPP

View file

@ -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 <sprout/config.hpp>
#include <sprout/algorithm/cxx14/iter_swap.hpp>
namespace sprout {
//
// 25.3.12 Random shuffle
//
template<typename RandomAccessIterator, typename RandomNumberGenerator>
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

View file

@ -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 <sprout/config.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
//
// 25.3.8 Remove
//
template<typename ForwardIterator, typename T>
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

View file

@ -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 <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.8 Remove
//
template<
typename InputIterator, typename OutputIterator, typename T,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.8 Remove
//
template<
typename InputIterator, typename OutputIterator, typename Predicate,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <sprout/config.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
//
// 25.3.8 Remove
//
template<typename ForwardIterator, typename Predicate>
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

View file

@ -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 <sprout/config.hpp>
namespace sprout {
//
// 25.3.5 Replace
//
template<typename ForwardIterator, typename T>
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

View file

@ -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 <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.5 Replace
//
template<
typename InputIterator, typename OutputIterator, typename T,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.5 Replace
//
template<
typename InputIterator, typename OutputIterator, typename Predicate, typename T,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <sprout/config.hpp>
namespace sprout {
//
// 25.3.5 Replace
//
template<typename ForwardIterator, typename Predicate, typename T>
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

View file

@ -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 <sprout/config.hpp>
#include <sprout/algorithm/cxx14/iter_swap.hpp>
namespace sprout {
//
// 25.3.10 Reverse
//
template<typename BidirectionalIterator>
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

View file

@ -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 <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.10 Reverse
//
template<
typename BidirectionalIterator, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <iterator>
#include <sprout/config.hpp>
#include <sprout/algorithm/cxx14/iter_swap.hpp>
namespace sprout {
//
// 25.3.11 Rotate
//
template<typename ForwardIterator>
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

View file

@ -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 <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
#include <sprout/algorithm/cxx14/copy.hpp>
namespace sprout {
//
// 25.3.11 Rotate
//
template<
typename ForwardIterator, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <sprout/config.hpp>
namespace sprout {
//
// 25.3.12 Random shuffle
//
template<typename RandomAccessIterator, typename UniformRandomNumberGenerator>
inline SPROUT_CXX14_CONSTEXPR void
shuffle(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g); // !!!
} // namespace sprout
#endif // #ifndef SPROUT_CXX14_ALGORITHM_SHUFFLE_HPP

View file

@ -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 <sprout/config.hpp>
namespace sprout {
//
// 25.3.13 Partitions
//
template<typename BidirectionalIterator, typename Predicate>
inline SPROUT_CXX14_CONSTEXPR BidirectionalIterator
stable_partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred); // !!!
} // namespace sprout
#endif // #ifndef SPROUT_CXX14_ALGORITHM_STABLE_PARTITION_HPP

View file

@ -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 <sprout/config.hpp>
#include <sprout/algorithm/cxx14/iter_swap.hpp>
namespace sprout {
//
// 25.3.3 swap
//
template<typename ForwardIterator1, typename ForwardIterator2>
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

View file

@ -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 <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.4 Transform
//
template<
typename InputIterator, typename OutputIterator, typename UnaryOperation,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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<sprout::is_iterator_outputable<OutputIterator>::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

View file

@ -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 <iterator>
#include <sprout/config.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
//
// 25.3.9 Unique
//
template<typename ForwardIterator>
inline SPROUT_CXX14_CONSTEXPR ForwardIterator
unique(ForwardIterator first, ForwardIterator last) {
if (first == last) {
return first;
}
ForwardIterator result = first;
typename std::iterator_traits<ForwardIterator>::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<typename ForwardIterator, typename BinaryPredicate>
inline SPROUT_CXX14_CONSTEXPR ForwardIterator
unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) {
if (first == last) {
return first;
}
ForwardIterator result = first;
typename std::iterator_traits<ForwardIterator>::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

View file

@ -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 <iterator>
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.9 Unique
//
template<
typename InputIterator, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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<InputIterator>::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<sprout::is_iterator_outputable<OutputIterator>::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<InputIterator>::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

View file

@ -9,21 +9,8 @@
#define SPROUT_ALGORITHM_FILL_HPP
#include <sprout/config.hpp>
namespace sprout {
//
// 25.3.6 Fill
//
template<typename ForwardIterator, typename T>
inline SPROUT_CXX14_CONSTEXPR void
fill(ForwardIterator first, ForwardIterator last, T const& value) {
while (first != last) {
*first++ = value;
}
}
} // namespace sprout
#include <sprout/algorithm/fixed/fill.hpp>
#include <sprout/algorithm/fit/fill.hpp>
#include <sprout/algorithm/cxx14/fill.hpp>
#endif // #ifndef SPROUT_ALGORITHM_FILL_HPP

View file

@ -9,27 +9,8 @@
#define SPROUT_ALGORITHM_FILL_N_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.6 Fill
//
template<
typename OutputIterator, typename Size, typename T,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/fixed/fill_n.hpp>
#include <sprout/algorithm/fit/fill_n.hpp>
#include <sprout/algorithm/cxx14/fill_n.hpp>
#endif // #ifndef SPROUT_ALGORITHM_FILL_N_HPP

View file

@ -9,21 +9,8 @@
#define SPROUT_ALGORITHM_GENERATE_HPP
#include <sprout/config.hpp>
namespace sprout {
//
// 25.3.7 Generate
//
template<typename ForwardIterator, typename Generator>
inline SPROUT_CXX14_CONSTEXPR void
generate(ForwardIterator first, ForwardIterator last, Generator gen) {
while (first != last) {
*first++ = gen();
}
}
} // namespace sprout
#include <sprout/algorithm/fixed/generate.hpp>
#include <sprout/algorithm/fit/generate.hpp>
#include <sprout/algorithm/cxx14/generate.hpp>
#endif // #ifndef SPROUT_ALGORITHM_GENERATE_HPP

View file

@ -9,25 +9,8 @@
#define SPROUT_ALGORITHM_GENERATE_N_HPP
#include <sprout/config.hpp>
namespace sprout {
//
// 25.3.7 Generate
//
template<
typename OutputIterator, typename Size, typename Generator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/fixed/generate_n.hpp>
#include <sprout/algorithm/fit/generate_n.hpp>
#include <sprout/algorithm/cxx14/generate_n.hpp>
#endif // #ifndef SPROUT_ALGORITHM_GENERATE_N_HPP

View file

@ -9,17 +9,6 @@
#define SPROUT_ALGORITHM_ITER_SWAP_HPP
#include <sprout/config.hpp>
#include <sprout/utility/swap.hpp>
namespace sprout {
//
// 25.3.3 swap
//
template<typename ForwardIterator1, typename ForwardIterator2>
inline SPROUT_CXX14_CONSTEXPR void
iter_swap(ForwardIterator1 a, ForwardIterator2 b) {
sprout::swap(*a, *b);
}
} // namespace sprout
#include <sprout/algorithm/cxx14/iter_swap.hpp>
#endif // #ifndef SPROUT_ALGORITHM_ITER_SWAP_HPP

View file

@ -9,72 +9,8 @@
#define SPROUT_ALGORITHM_MODIFYIING_HPP
#include <sprout/config.hpp>
#include <sprout/algorithm/copy.hpp>
#include <sprout/algorithm/copy_n.hpp>
#include <sprout/algorithm/copy_if.hpp>
#include <sprout/algorithm/copy_backward.hpp>
#include <sprout/algorithm/move.hpp>
#include <sprout/algorithm/move_backward.hpp>
#include <sprout/algorithm/swap_ranges.hpp>
#include <sprout/algorithm/iter_swap.hpp>
#include <sprout/algorithm/transform.hpp>
#include <sprout/algorithm/replace.hpp>
#include <sprout/algorithm/replace_if.hpp>
#include <sprout/algorithm/replace_copy.hpp>
#include <sprout/algorithm/replace_copy_if.hpp>
#include <sprout/algorithm/fill.hpp>
#include <sprout/algorithm/fill_n.hpp>
#include <sprout/algorithm/generate.hpp>
#include <sprout/algorithm/generate_n.hpp>
#include <sprout/algorithm/unfold.hpp>
#include <sprout/algorithm/unfold_n.hpp>
#include <sprout/algorithm/recurrence.hpp>
#include <sprout/algorithm/recurrence_n.hpp>
#include <sprout/algorithm/remove.hpp>
#include <sprout/algorithm/remove_if.hpp>
#include <sprout/algorithm/remove_copy.hpp>
#include <sprout/algorithm/remove_copy_if.hpp>
#include <sprout/algorithm/unique.hpp>
#include <sprout/algorithm/unique_copy.hpp>
#include <sprout/algorithm/reverse.hpp>
#include <sprout/algorithm/reverse_copy.hpp>
#include <sprout/algorithm/rotate.hpp>
#include <sprout/algorithm/rotate_copy.hpp>
#include <sprout/algorithm/random_shuffle.hpp>
#include <sprout/algorithm/shuffle.hpp>
#include <sprout/algorithm/shuffle_result.hpp>
#include <sprout/algorithm/partition.hpp>
#include <sprout/algorithm/stable_partition.hpp>
#include <sprout/algorithm/partition_copy.hpp>
#include <sprout/algorithm/stable_partition_copy.hpp>
#include <sprout/algorithm/sort.hpp>
#include <sprout/algorithm/stable_sort.hpp>
#include <sprout/algorithm/partial_sort.hpp>
#include <sprout/algorithm/nth_element.hpp>
#include <sprout/algorithm/merge.hpp>
#include <sprout/algorithm/inplace_merge.hpp>
#include <sprout/algorithm/set_union.hpp>
#include <sprout/algorithm/set_intersection.hpp>
#include <sprout/algorithm/set_difference.hpp>
#include <sprout/algorithm/set_symmetric_difference.hpp>
#include <sprout/algorithm/push_heap.hpp>
#include <sprout/algorithm/pop_heap.hpp>
#include <sprout/algorithm/make_heap.hpp>
#include <sprout/algorithm/make_partial_heap.hpp>
#include <sprout/algorithm/sort_heap.hpp>
#include <sprout/algorithm/next_permutation.hpp>
#include <sprout/algorithm/prev_permutation.hpp>
#include <sprout/algorithm/copy_while.hpp>
#include <sprout/algorithm/copy_until.hpp>
#include <sprout/algorithm/clamp_range.hpp>
#include <sprout/algorithm/clamp_range_copy.hpp>
#include <sprout/algorithm/swap_element.hpp>
#include <sprout/algorithm/swap_element_copy.hpp>
#include <sprout/algorithm/random_swap.hpp>
#include <sprout/algorithm/random_swap_result.hpp>
#include <sprout/algorithm/bogo_sort.hpp>
#include <sprout/algorithm/bogo_sort_result.hpp>
#include <sprout/algorithm/bozo_sort.hpp>
#include <sprout/algorithm/bozo_sort_result.hpp>
#include <sprout/algorithm/fixed.hpp>
#include <sprout/algorithm/fit.hpp>
#include <sprout/algorithm/cxx14.hpp>
#endif // #ifndef SPROUT_ALGORITHM_MODIFYIING_HPP

View file

@ -9,25 +9,6 @@
#define SPROUT_ALGORITHM_MOVE_HPP
#include <sprout/config.hpp>
#include <sprout/type_traits/enabler_if.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
//
// 25.3.2 Move
//
template<
typename InputIterator, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/cxx14/move_backward.hpp>
#endif // #ifndef SPROUT_ALGORITHM_MOVE_HPP

View file

@ -9,25 +9,6 @@
#define SPROUT_ALGORITHM_MOVE_BACKWARD_HPP
#include <sprout/config.hpp>
#include <sprout/type_traits/enabler_if.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
//
// 25.3.2 Move
//
template<
typename InputIterator, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/cxx14/move_backward.hpp>
#endif // #ifndef SPROUT_ALGORITHM_MOVE_BACKWARD_HPP

View file

@ -9,29 +9,8 @@
#define SPROUT_ALGORITHM_PARTITION_HPP
#include <sprout/config.hpp>
#include <sprout/algorithm/iter_swap.hpp>
#include <sprout/algorithm/find_if.hpp>
#include <sprout/algorithm/find_if_not.hpp>
namespace sprout {
//
// 25.3.13 Partitions
//
template<typename ForwardIterator, typename Predicate>
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 <sprout/algorithm/fixed/partition.hpp>
#include <sprout/algorithm/fit/partition.hpp>
#include <sprout/algorithm/cxx14/partition.hpp>
#endif // #ifndef SPROUT_ALGORITHM_PARTITION_HPP

View file

@ -9,18 +9,8 @@
#define SPROUT_ALGORITHM_PARTITION_COPY_HPP
#include <sprout/config.hpp>
#include <sprout/utility/pair.hpp>
namespace sprout {
//
// 25.3.13 Partitions
//
template<typename InputIterator, typename OutputIterator1, typename OutputIterator2, typename Predicate>
inline SPROUT_CXX14_CONSTEXPR sprout::pair<OutputIterator1, OutputIterator2>
partition_copy(InputIterator first, InputIterator last, OutputIterator1 out_true, OutputIterator2 out_false, Predicate pred); // !!!
} // namespace sprout
#include <sprout/algorithm/fixed/partition_copy.hpp>
#include <sprout/algorithm/fit/partition_copy.hpp>
#include <sprout/algorithm/cxx14/partition_copy.hpp>
#endif // #ifndef SPROUT_ALGORITHM_PARTITION_COPY_HPP

View file

@ -9,22 +9,6 @@
#define SPROUT_ALGORITHM_RANDOM_SHUFFLE_HPP
#include <sprout/config.hpp>
#include <sprout/algorithm/iter_swap.hpp>
namespace sprout {
//
// 25.3.12 Random shuffle
//
template<typename RandomAccessIterator, typename RandomNumberGenerator>
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 <sprout/algorithm/cxx14/random_shuffle.hpp>
#endif // #ifndef SPROUT_ALGORITHM_RANDOM_SHUFFLE_HPP

View file

@ -9,26 +9,8 @@
#define SPROUT_ALGORITHM_REMOVE_HPP
#include <sprout/config.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
//
// 25.3.8 Remove
//
template<typename ForwardIterator, typename T>
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 <sprout/algorithm/fixed/remove.hpp>
#include <sprout/algorithm/fit/remove.hpp>
#include <sprout/algorithm/cxx14/remove.hpp>
#endif // #ifndef SPROUT_ALGORITHM_REMOVE_HPP

View file

@ -9,29 +9,8 @@
#define SPROUT_ALGORITHM_REMOVE_COPY_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.8 Remove
//
template<
typename InputIterator, typename OutputIterator, typename T,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/fixed/remove_copy.hpp>
#include <sprout/algorithm/fit/remove_copy.hpp>
#include <sprout/algorithm/cxx14/remove_copy.hpp>
#endif // #ifndef SPROUT_ALGORITHM_REMOVE_COPY_HPP

View file

@ -9,29 +9,8 @@
#define SPROUT_ALGORITHM_REMOVE_COPY_IF_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.8 Remove
//
template<
typename InputIterator, typename OutputIterator, typename Predicate,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/fixed/remove_copy_if.hpp>
#include <sprout/algorithm/fit/remove_copy_if.hpp>
#include <sprout/algorithm/cxx14/remove_copy_if.hpp>
#endif // #ifndef SPROUT_ALGORITHM_REMOVE_COPY_IF_HPP

View file

@ -9,26 +9,8 @@
#define SPROUT_ALGORITHM_REMOVE_IF_HPP
#include <sprout/config.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
//
// 25.3.8 Remove
//
template<typename ForwardIterator, typename Predicate>
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 <sprout/algorithm/fixed/remove_if.hpp>
#include <sprout/algorithm/fit/remove_if.hpp>
#include <sprout/algorithm/cxx14/remove_if.hpp>
#endif // #ifndef SPROUT_ALGORITHM_REMOVE_IF_HPP

View file

@ -9,23 +9,8 @@
#define SPROUT_ALGORITHM_REPLACE_HPP
#include <sprout/config.hpp>
namespace sprout {
//
// 25.3.5 Replace
//
template<typename ForwardIterator, typename T>
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 <sprout/algorithm/fixed/replace.hpp>
#include <sprout/algorithm/fit/replace.hpp>
#include <sprout/algorithm/cxx14/replace.hpp>
#endif // #ifndef SPROUT_ALGORITHM_REPLACE_HPP

View file

@ -9,27 +9,8 @@
#define SPROUT_ALGORITHM_REPLACE_COPY_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.5 Replace
//
template<
typename InputIterator, typename OutputIterator, typename T,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/fixed/replace_copy.hpp>
#include <sprout/algorithm/fit/replace_copy.hpp>
#include <sprout/algorithm/cxx14/replace_copy.hpp>
#endif // #ifndef SPROUT_ALGORITHM_REPLACE_COPY_HPP

View file

@ -9,27 +9,8 @@
#define SPROUT_ALGORITHM_REPLACE_COPY_IF_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.5 Replace
//
template<
typename InputIterator, typename OutputIterator, typename Predicate, typename T,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/fixed/replace_copy_if.hpp>
#include <sprout/algorithm/fit/replace_copy_if.hpp>
#include <sprout/algorithm/cxx14/replace_copy_if.hpp>
#endif // #ifndef SPROUT_ALGORITHM_REPLACE_COPY_IF_HPP

View file

@ -9,23 +9,8 @@
#define SPROUT_ALGORITHM_REPLACE_IF_HPP
#include <sprout/config.hpp>
namespace sprout {
//
// 25.3.5 Replace
//
template<typename ForwardIterator, typename Predicate, typename T>
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 <sprout/algorithm/fixed/replace_if.hpp>
#include <sprout/algorithm/fit/replace_if.hpp>
#include <sprout/algorithm/cxx14/replace_if.hpp>
#endif // #ifndef SPROUT_ALGORITHM_REPLACE_IF_HPP

View file

@ -9,22 +9,8 @@
#define SPROUT_ALGORITHM_REVERSE_HPP
#include <sprout/config.hpp>
#include <sprout/algorithm/iter_swap.hpp>
namespace sprout {
//
// 25.3.10 Reverse
//
template<typename BidirectionalIterator>
inline SPROUT_CXX14_CONSTEXPR void
reverse(BidirectionalIterator first, BidirectionalIterator last) {
for (; first != last && first != --last; ++first) {
sprout::iter_swap(first, last);
}
}
} // namespace sprout
#include <sprout/algorithm/fixed/reverse.hpp>
#include <sprout/algorithm/fit/reverse.hpp>
#include <sprout/algorithm/cxx14/reverse.hpp>
#endif // #ifndef SPROUT_ALGORITHM_REVERSE_HPP

View file

@ -9,27 +9,8 @@
#define SPROUT_ALGORITHM_REVERSE_COPY_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.10 Reverse
//
template<
typename BidirectionalIterator, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/fixed/reverse_copy.hpp>
#include <sprout/algorithm/fit/reverse_copy.hpp>
#include <sprout/algorithm/cxx14/reverse_copy.hpp>
#endif // #ifndef SPROUT_ALGORITHM_REVERSE_COPY_HPP

View file

@ -8,54 +8,9 @@
#ifndef SPROUT_ALGORITHM_ROTATE_HPP
#define SPROUT_ALGORITHM_ROTATE_HPP
#include <iterator>
#include <sprout/config.hpp>
#include <sprout/algorithm/iter_swap.hpp>
namespace sprout {
//
// 25.3.11 Rotate
//
template<typename ForwardIterator>
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 <sprout/algorithm/fixed/rotate.hpp>
#include <sprout/algorithm/fit/rotate.hpp>
#include <sprout/algorithm/cxx14/rotate.hpp>
#endif // #ifndef SPROUT_ALGORITHM_ROTATE_HPP

View file

@ -9,25 +9,8 @@
#define SPROUT_ALGORITHM_ROTATE_COPY_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
#include <sprout/algorithm/copy.hpp>
namespace sprout {
//
// 25.3.11 Rotate
//
template<
typename ForwardIterator, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/fixed/rotate_copy.hpp>
#include <sprout/algorithm/fit/rotate_copy.hpp>
#include <sprout/algorithm/cxx14/rotate_copy.hpp>
#endif // #ifndef SPROUT_ALGORITHM_ROTATE_COPY_HPP

View file

@ -9,17 +9,8 @@
#define SPROUT_ALGORITHM_SHUFFLE_HPP
#include <sprout/config.hpp>
namespace sprout {
//
// 25.3.12 Random shuffle
//
template<typename RandomAccessIterator, typename UniformRandomNumberGenerator>
inline SPROUT_CXX14_CONSTEXPR void
shuffle(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g); // !!!
} // namespace sprout
#include <sprout/algorithm/fixed/shuffle.hpp>
#include <sprout/algorithm/fit/shuffle.hpp>
#include <sprout/algorithm/cxx14/shuffle.hpp>
#endif // #ifndef SPROUT_ALGORITHM_SHUFFLE_HPP

View file

@ -9,18 +9,8 @@
#define SPROUT_ALGORITHM_STABLE_PARTITION_HPP
#include <sprout/config.hpp>
namespace sprout {
//
// 25.3.13 Partitions
//
template<typename BidirectionalIterator, typename Predicate>
inline SPROUT_CXX14_CONSTEXPR BidirectionalIterator
stable_partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred); // !!!
} // namespace sprout
#include <sprout/algorithm/fixed/stable_partition.hpp>
#include <sprout/algorithm/fit/stable_partition.hpp>
#include <sprout/algorithm/cxx14/stable_partition.hpp>
#endif // #ifndef SPROUT_ALGORITHM_STABLE_PARTITION_HPP

View file

@ -9,20 +9,6 @@
#define SPROUT_ALGORITHM_SWAP_RANGES_HPP
#include <sprout/config.hpp>
#include <sprout/algorithm/iter_swap.hpp>
namespace sprout {
//
// 25.3.3 swap
//
template<typename ForwardIterator1, typename ForwardIterator2>
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 <sprout/algorithm/cxx14/swap_ranges.hpp>
#endif // #ifndef SPROUT_ALGORITHM_SWAP_RANGES_HPP

View file

@ -9,38 +9,8 @@
#define SPROUT_ALGORITHM_TRANSFORM_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.4 Transform
//
template<
typename InputIterator, typename OutputIterator, typename UnaryOperation,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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<sprout::is_iterator_outputable<OutputIterator>::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 <sprout/algorithm/fixed/transform.hpp>
#include <sprout/algorithm/fit/transform.hpp>
#include <sprout/algorithm/cxx14/transform.hpp>
#endif // #ifndef SPROUT_ALGORITHM_TRANSFORM_HPP

View file

@ -8,51 +8,9 @@
#ifndef SPROUT_ALGORITHM_UNIQUE_HPP
#define SPROUT_ALGORITHM_UNIQUE_HPP
#include <iterator>
#include <sprout/config.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
//
// 25.3.9 Unique
//
template<typename ForwardIterator>
inline SPROUT_CXX14_CONSTEXPR ForwardIterator
unique(ForwardIterator first, ForwardIterator last) {
if (first == last) {
return first;
}
ForwardIterator result = first;
typename std::iterator_traits<ForwardIterator>::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<typename ForwardIterator, typename BinaryPredicate>
inline SPROUT_CXX14_CONSTEXPR ForwardIterator
unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) {
if (first == last) {
return first;
}
ForwardIterator result = first;
typename std::iterator_traits<ForwardIterator>::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 <sprout/algorithm/fixed/unique.hpp>
#include <sprout/algorithm/fit/unique.hpp>
#include <sprout/algorithm/cxx14/unique.hpp>
#endif // #ifndef SPROUT_ALGORITHM_UNIQUE_HPP

View file

@ -8,57 +8,9 @@
#ifndef SPROUT_ALGORITHM_UNIQUE_COPY_HPP
#define SPROUT_ALGORITHM_UNIQUE_COPY_HPP
#include <iterator>
#include <sprout/config.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/type_traits/enabler_if.hpp>
namespace sprout {
//
// 25.3.9 Unique
//
template<
typename InputIterator, typename OutputIterator,
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::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<InputIterator>::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<sprout::is_iterator_outputable<OutputIterator>::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<InputIterator>::value_type value = *first++;
*result++ = value;
for (; first != last; ++first) {
if (!pred(value, *first)) {
value = *first;
*result++ = value;
}
}
return result;
}
} // namespace sprout
#include <sprout/algorithm/fixed/unique_copy.hpp>
#include <sprout/algorithm/fit/unique_copy.hpp>
#include <sprout/algorithm/cxx14/unique_copy.hpp>
#endif // #ifndef SPROUT_ALGORITHM_UNIQUE_COPY_HPP

View file

@ -17,10 +17,10 @@
#include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/reverse_iterator.hpp>
#include <sprout/algorithm/copy.hpp>
#include <sprout/algorithm/move.hpp>
#include <sprout/algorithm/fill_n.hpp>
#include <sprout/algorithm/swap_ranges.hpp>
#include <sprout/algorithm/cxx14/copy.hpp>
#include <sprout/algorithm/cxx14/move.hpp>
#include <sprout/algorithm/cxx14/fill_n.hpp>
#include <sprout/algorithm/cxx14/swap_ranges.hpp>
#include <sprout/utility/swap.hpp>
#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION
# include <sprout/iterator/index_iterator.hpp>

View file

@ -10,9 +10,7 @@
#include <cstddef>
#include <climits>
#include <cstring>
#include <string>
#include <algorithm>
#include <stdexcept>
#include <type_traits>
#include <sprout/config.hpp>
@ -25,6 +23,7 @@
#include <sprout/algorithm/equal.hpp>
#include <sprout/algorithm/fixed/transform.hpp>
#include <sprout/algorithm/fixed/fill.hpp>
#include <sprout/algorithm/cxx14/fill.hpp>
#include <sprout/numeric/accumulate.hpp>
#include <sprout/operation/fixed/set.hpp>
#include <sprout/utility/forward.hpp>
@ -322,7 +321,7 @@ namespace sprout {
}
w_[wshift] = w_[0] << offset;
}
std::fill(w_ + 0, w_ + wshift, static_cast<word_type>(0));
sprout::fill(w_ + 0, w_ + wshift, static_cast<word_type>(0));
}
}
SPROUT_CONSTEXPR base_bitset<N>
@ -351,7 +350,7 @@ namespace sprout {
}
w_[limit] = w_[N-1] >> offset;
}
std::fill(w_ + limit + 1, w_ + N, static_cast<word_type>(0));
sprout::fill(w_ + limit + 1, w_ + N, static_cast<word_type>(0));
}
}
SPROUT_CONSTEXPR base_bitset<N>
@ -392,7 +391,7 @@ namespace sprout {
}
SPROUT_CXX14_CONSTEXPR void
do_reset() SPROUT_NOEXCEPT {
std::memset(w_, 0, N * sprout::detail::sizeof_<word_type>::value);
sprout::fill(w_ + 0, w_ + N, static_cast<word_type>(0));
}
SPROUT_CONSTEXPR bool

View file

@ -394,12 +394,12 @@ namespace sprout {
-> decltype(
sprout::detail::get_bound_helper::get_bound<
sprout::detail::bound_position<I, typename std::remove_reference<Bounds>::type, ArgSize>::value
>(std::forward<Bounds>(bound_args))
>(sprout::forward<Bounds>(bound_args))
)
{
return sprout::detail::get_bound_helper::get_bound<
sprout::detail::bound_position<I, typename std::remove_reference<Bounds>::type, ArgSize>::value
>(std::forward<Bounds>(bound_args));
>(sprout::forward<Bounds>(bound_args));
}
} // namespace detail

View file

@ -15,6 +15,8 @@
#include <sprout/container/functions.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
#include <sprout/utility/swap.hpp>
#include <sprout/utility/move.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
namespace range {
@ -95,8 +97,8 @@ namespace sprout {
}
template<typename Iterator2>
SPROUT_CXX14_CONSTEXPR range_container<Iterator>& operator=(range_container<Iterator2>&& rhs) {
first_ = std::move(rhs.first_);
last_ = std::move(rhs.last_);
first_ = sprout::move(rhs.first_);
last_ = sprout::move(rhs.last_);
return *this;
}
};

View file

@ -11,15 +11,14 @@
#include <cstddef>
#include <cstdio>
#include <string>
#include <algorithm>
#include <sprout/config.hpp>
#include <sprout/functional/bind2nd.hpp>
#include <sprout/iterator/ptr_index_iterator.hpp>
#include <sprout/algorithm/find_if.hpp>
#include <sprout/algorithm/tristate_lexicographical_compare.hpp>
#include <sprout/algorithm/copy.hpp>
#include <sprout/algorithm/copy_backward.hpp>
#include <sprout/algorithm/fill.hpp>
#include <sprout/algorithm/cxx14/copy.hpp>
#include <sprout/algorithm/cxx14/copy_backward.hpp>
#include <sprout/algorithm/cxx14/fill.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/cstring/strlen.hpp>

View file

@ -24,7 +24,7 @@
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
#include <sprout/algorithm/find.hpp>
#include <sprout/algorithm/swap_ranges.hpp>
#include <sprout/algorithm/cxx14/swap_ranges.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/swap.hpp>
#include <sprout/type_traits/identity.hpp>

View file

@ -8,7 +8,6 @@
#ifndef SPROUT_SUB_ARRAY_SUB_ARRAY_HPP
#define SPROUT_SUB_ARRAY_SUB_ARRAY_HPP
#include <algorithm>
#include <utility>
#include <stdexcept>
#include <type_traits>
@ -17,7 +16,9 @@
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/cxx14/fill_n.hpp>
#include <sprout/utility/swap.hpp>
#include <sprout/utility/move.hpp>
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<typename Container2>
SPROUT_CXX14_CONSTEXPR void swap(sub_array<Container2>& other)
@ -329,9 +330,9 @@ namespace sprout {
}
template<typename Container2>
SPROUT_CXX14_CONSTEXPR sub_array& operator=(sub_array<Container2>&& 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() {

View file

@ -9,9 +9,9 @@
#define SPROUT_UTILITY_STRING_IO_HPP
#include <iterator>
#include <algorithm>
#include <ios>
#include <sprout/config.hpp>
#include <sprout/algorithm/cxx14/copy.hpp>
#include <sprout/utility/string_ref/string_ref.hpp>
namespace sprout {
@ -21,7 +21,7 @@ namespace sprout {
template<typename T, typename Traits, typename StreamTraits>
inline std::basic_ostream<T, StreamTraits>&
operator<<(std::basic_ostream<T, StreamTraits>& lhs, sprout::basic_string_ref<T, Traits> const& rhs) {
std::copy(rhs.begin(), rhs.end(), std::ostreambuf_iterator<T, StreamTraits>(lhs));
sprout::copy(rhs.begin(), rhs.end(), std::ostreambuf_iterator<T, StreamTraits>(lhs));
return lhs;
}
} // namespace sprout

View file

@ -9,13 +9,14 @@
#define SPROUT_UUID_IO_HPP
#include <cstddef>
#include <algorithm>
#include <iterator>
#include <ios>
#include <ostream>
#include <istream>
#include <locale>
#include <sprout/config.hpp>
#include <sprout/algorithm/find.hpp>
#include <sprout/algorithm/cxx14/copy.hpp>
#include <sprout/string.hpp>
#include <sprout/uuid/uuid.hpp>
#include <sprout/uuid/detail/table.hpp>
@ -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<sprout::uuids::uuid::value_type>(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;

View file

@ -9,7 +9,6 @@
#define SPROUT_UUID_UUID_HPP
#include <cstddef>
#include <algorithm>
#include <utility>
#include <stdexcept>
#include <type_traits>
@ -18,6 +17,8 @@
#include <sprout/iterator/reverse_iterator.hpp>
#include <sprout/algorithm/equal.hpp>
#include <sprout/algorithm/lexicographical_compare.hpp>
#include <sprout/algorithm/cxx14/fill_n.hpp>
#include <sprout/algorithm/cxx14/swap_ranges.hpp>
#if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION
# include <sprout/iterator/index_iterator.hpp>
#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