diff --git a/CHANGES b/CHANGES
index 847db89a4fd..16b87522afa 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,22 @@
------------------------------------------------------------------------
The list of most significant changes made over time in Parallel STL.
+Parallel STL 20180619 release
+PSTL_VERSION == 106
+
+Features / APIs:
+
+- More algorithms support parallel and vector execution policies:
+ adjacent_difference, partition, reverse, reverse_copy, rotate_copy,
+ stable_partition.
+- More algorithms support parallel execution policies:
+ inplace_merge, partial_sort_copy.
+- Split algorithm declarations and implementation by files.
+ (by Thomas Rodgers).
+- CMake support - Preview Feature
+ (by Amit Prakash Ambasta and Henry Schreiner)
+
+------------------------------------------------------------------------
Parallel STL release within Intel(R) Parallel Studio XE 2018 Update 3
PSTL_VERSION == 105
@@ -83,7 +99,7 @@ Features / APIs:
- Aligned the implementation with the draft N4659 of the C++ standard.
In particular, inner_product no longer supports execution policies.
-- reduce and transform_reduce support unseq and par_unseq execution
+- reduce and transform_reduce support unseq and par_unseq execution
policies if std::plus<> is used for reduction.
- Added counting_iterator and zip_iterator to support advanced use cases.
To use, include pstl/iterators.h header file.
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000000..75d15ecdb4d
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,70 @@
+# Copyright (c) 2018 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+#
+
+cmake_minimum_required(VERSION 3.1)
+
+set(PARALLELSTL_VERSION_FILE "include/pstl/internal/pstl_config.h")
+file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define PSTL_VERSION .*$")
+string(REGEX MATCH "#define PSTL_VERSION (.*)$" PARALLELSTL_VERSION_SOURCE "${PARALLELSTL_VERSION_SOURCE}")
+math(EXPR VERSION_MAJOR "${PARALLELSTL_VERSION_SOURCE} / 100")
+math(EXPR VERSION_MINOR "${PARALLELSTL_VERSION_SOURCE} % 100")
+
+project(ParallelSTL VERSION ${VERSION_MAJOR}.${VERSION_MINOR} LANGUAGES CXX)
+
+option(PARALLELSTL_USE_PARALLEL_POLICIES "Enable parallel policies" ON)
+set(PARALLELSTL_BACKEND "tbb" CACHE STRING "Threading backend; defaults to TBB")
+
+include(CMakePackageConfigHelpers)
+
+add_library(ParallelSTL INTERFACE)
+add_library(pstl::ParallelSTL ALIAS ParallelSTL)
+
+if (PARALLELSTL_USE_PARALLEL_POLICIES)
+ if (PARALLELSTL_BACKEND STREQUAL "tbb")
+ find_package(TBB 2018 REQUIRED tbb)
+ message(STATUS "Parallel STL uses TBB ${TBB_VERSION} (interface version: ${TBB_INTERFACE_VERSION})")
+ target_link_libraries(ParallelSTL INTERFACE TBB::tbb)
+ else()
+ if (TARGET ${PARALLELSTL_BACKEND})
+ target_link_libraries(ParallelSTL INTERFACE ${PARALLELSTL_BACKEND})
+ else()
+ find_package(${PARALLELSTL_BACKEND} REQUIRED)
+ target_link_libraries(ParallelSTL INTERFACE ${${PARALLELSTL_BACKEND}_IMPORTED_TARGETS})
+ endif()
+ endif()
+else()
+ target_add_definitions(ParallelSTL INTERFACE PSTL_USE_PARALLEL_POLICIES=0)
+endif()
+
+target_include_directories(ParallelSTL
+ INTERFACE
+ $
+ $)
+
+write_basic_package_version_file(
+ ${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY AnyNewerVersion)
+
+configure_file(
+ ParallelSTLConfig.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake
+ @ONLY)
+
+export(TARGETS ParallelSTL NAMESPACE pstl:: FILE ParallelSTLTargets.cmake)
+export(PACKAGE ParallelSTL)
diff --git a/ParallelSTLConfig.cmake.in b/ParallelSTLConfig.cmake.in
new file mode 100644
index 00000000000..d0cf5011853
--- /dev/null
+++ b/ParallelSTLConfig.cmake.in
@@ -0,0 +1,27 @@
+# Copyright (c) 2018 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+#
+
+include(CMakeFindDependencyMacro)
+
+set(PARALLELSTL_BACKEND "@PARALLELSTL_BACKEND@")
+
+if(PARALLELSTL_BACKEND STREQUAL "tbb")
+ find_dependency(TBB 2018 REQUIRED tbb)
+endif()
+
+include("${CMAKE_CURRENT_LIST_DIR}/ParallelSTLTargets.cmake")
diff --git a/README.md b/README.md
index 209f1a4947a..eaf79072eb9 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# Parallel STL
-[![Stable release](https://img.shields.io/badge/version-20180529-green.svg)](https://github.com/intel/parallelstl/releases/tag/20180529)
+[![Stable release](https://img.shields.io/badge/version-20180619-green.svg)](https://github.com/intel/parallelstl/releases/tag/20180619)
[![Apache License Version 2.0](https://img.shields.io/badge/license-Apache_2.0-green.svg)](LICENSE)
Parallel STL is an implementation of the C++ standard library algorithms with support for execution policies,
diff --git a/include/pstl/algorithm b/include/pstl/algorithm
index 859c5621ab5..68878169038 100644
--- a/include/pstl/algorithm
+++ b/include/pstl/algorithm
@@ -21,913 +21,15 @@
#ifndef __PSTL_algorithm
#define __PSTL_algorithm
-#include
-
#include "internal/pstl_config.h"
-#include "internal/utils.h"
-#include "internal/algorithm_impl.h"
-#include "internal/numeric_impl.h" /* count and count_if use pattern_transform_reduce */
-
-namespace std {
-
-// [alg.any_of]
-
-template
-pstl::internal::enable_if_execution_policy
-any_of(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Predicate pred) {
- using namespace pstl::internal;
- return pattern_any_of( first, last, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-// [alg.all_of]
-
-template
-pstl::internal::enable_if_execution_policy
-all_of(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Pred pred) {
- return !any_of(std::forward(exec), first, last, pstl::internal::not_pred(pred));
-}
-
-// [alg.none_of]
-
-template
-pstl::internal::enable_if_execution_policy
-none_of(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Predicate pred) {
- return !any_of( std::forward(exec), first, last, pred );
-}
-
-// [alg.foreach]
-
-template
-pstl::internal::enable_if_execution_policy
-for_each(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Function f) {
- using namespace pstl::internal;
- pattern_walk1(
- first, last, f,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-for_each_n(ExecutionPolicy&& exec, ForwardIterator first, Size n, Function f) {
- using namespace pstl::internal;
- return pattern_walk1_n(first, n, f,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-// [alg.find]
-
-template
-pstl::internal::enable_if_execution_policy
-find_if(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Predicate pred) {
- using namespace pstl::internal;
- return pattern_find_if( first, last, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-find_if_not(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last,
-Predicate pred) {
- return find_if(std::forward(exec), first, last, pstl::internal::not_pred(pred));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-find(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last,
-const T& value) {
- return find_if(std::forward(exec), first, last, pstl::internal::equal_value(value));
-}
-
-// [alg.find.end]
-template
-pstl::internal::enable_if_execution_policy
-find_end(ExecutionPolicy &&exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 s_first, ForwardIterator2 s_last, BinaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_find_end(first, last, s_first, s_last, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-find_end(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 s_first, ForwardIterator2 s_last) {
- return find_end(std::forward(exec), first, last, s_first, s_last, pstl::internal::pstl_equal());
-}
-
-// [alg.find_first_of]
-template
-pstl::internal::enable_if_execution_policy
-find_first_of(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 s_first, ForwardIterator2 s_last, BinaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_find_first_of(first, last, s_first, s_last, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-find_first_of(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 s_first, ForwardIterator2 s_last) {
- return find_first_of(std::forward(exec), first, last, s_first, s_last, pstl::internal::pstl_equal());
-}
-
-// [alg.adjacent_find]
-template< class ExecutionPolicy, class ForwardIterator >
-pstl::internal::enable_if_execution_policy
-adjacent_find(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last) {
- using namespace pstl::internal;
- return pattern_adjacent_find(first, last, pstl::internal::pstl_equal(),
- is_parallelization_preferred(exec),
- is_vectorization_preferred(exec), /*first_semantic*/ false);
-}
-
-template< class ExecutionPolicy, class ForwardIterator, class BinaryPredicate>
-pstl::internal::enable_if_execution_policy
-adjacent_find(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, BinaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_adjacent_find(first, last, pred,
- is_parallelization_preferred(exec),
- is_vectorization_preferred(exec), /*first_semantic*/ false);
-}
-
-// [alg.count]
-
-// Implementation note: count and count_if call the pattern directly instead of calling std::transform_reduce
-// so that we do not have to include .
-
-template
-pstl::internal::enable_if_execution_policy::difference_type>
-count(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, const T& value) {
- typedef typename iterator_traits::reference value_type;
- using namespace pstl::internal;
- return pattern_count(first, last, [&value](const value_type x) {return value==x;},
- is_parallelization_preferred(exec),
- is_vectorization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy::difference_type>
-count_if(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Predicate pred) {
- using namespace pstl::internal;
- return pattern_count(first, last, pred,
- is_parallelization_preferred(exec),
- is_vectorization_preferred(exec));
-}
-
-// [alg.search]
-
-template
-pstl::internal::enable_if_execution_policy
-search(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 s_first, ForwardIterator2 s_last, BinaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_search(first, last, s_first, s_last, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-search(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 s_first, ForwardIterator2 s_last) {
- return search(std::forward(exec), first, last, s_first, s_last, pstl::internal::pstl_equal());
-}
-
-template
-pstl::internal::enable_if_execution_policy
-search_n(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Size count, const T& value, BinaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_search_n(first, last, count, value, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-search_n(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Size count, const T& value) {
- return search_n(std::forward(exec), first, last, count, value, pstl::internal::pstl_equal());
-}
-
-// [alg.copy]
-
-template
-pstl::internal::enable_if_execution_policy
-copy(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result) {
- using namespace pstl::internal;
- const auto is_vector = is_vectorization_preferred(exec);
-
- return pattern_walk2_brick(first, last, result, [is_vector](ForwardIterator1 begin, ForwardIterator1 end, ForwardIterator2 res){
- return brick_copy(begin, end, res, is_vector);
- }, is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-copy_n(ExecutionPolicy&& exec, ForwardIterator1 first, Size n, ForwardIterator2 result) {
- using namespace pstl::internal;
- const auto is_vector = is_vectorization_preferred(exec);
-
- return pattern_walk2_brick_n(first, n, result, [is_vector](ForwardIterator1 begin, Size sz, ForwardIterator2 res){
- return brick_copy_n(begin, sz, res, is_vector);
- }, is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-copy_if(ExecutionPolicy&& exec,
- ForwardIterator1 first, ForwardIterator1 last,
- ForwardIterator2 result, Predicate pred) {
- using namespace pstl::internal;
- return pattern_copy_if(
- first, last, result, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-// [alg.swap]
-
-template
-pstl::internal::enable_if_execution_policy
-swap_ranges(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2) {
- using namespace pstl::internal;
- typedef typename iterator_traits::reference reference_type1;
- typedef typename iterator_traits::reference reference_type2;
- return pattern_walk2(first1, last1, first2,
- [](reference_type1 x, reference_type2 y) {
- using std::swap;
- swap(x, y);
- },
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-// [alg.transform]
-
-template
-pstl::internal::enable_if_execution_policy
-transform( ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result, UnaryOperation op ) {
- typedef typename iterator_traits::reference input_type;
- typedef typename iterator_traits::reference output_type;
- using namespace pstl::internal;
- return pattern_walk2(first, last, result,
- [op](input_type x, output_type y ) mutable { y = op(x);},
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-transform( ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator result, BinaryOperation op ) {
- typedef typename iterator_traits::reference input1_type;
- typedef typename iterator_traits::reference input2_type;
- typedef typename iterator_traits::reference output_type;
- using namespace pstl::internal;
- return pattern_walk3(first1, last1, first2, result, [op](input1_type x, input2_type y, output_type z) mutable {z = op(x,y);},
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-// [alg.replace]
-
-template
-pstl::internal::enable_if_execution_policy
-replace_if(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, UnaryPredicate pred, const T& new_value) {
- using namespace pstl::internal;
- typedef typename iterator_traits::reference element_type;
- pattern_walk1(first, last, [&pred, &new_value] (element_type elem) {
- if (pred(elem)) {
- elem = new_value;
- }
- },
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-replace(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value) {
- replace_if(std::forward(exec), first, last, pstl::internal::equal_value(old_value), new_value);
-}
-
-template
-pstl::internal::enable_if_execution_policy
-replace_copy_if(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result, UnaryPredicate pred, const T& new_value) {
- typedef typename iterator_traits::reference input_type;
- typedef typename iterator_traits::reference output_type;
- using namespace pstl::internal;
- return pattern_walk2(
- first, last, result,
- [pred, &new_value](input_type x, output_type y) mutable { y = pred(x) ? new_value : x; },
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-replace_copy(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result, const T& old_value, const T& new_value) {
- return replace_copy_if(std::forward(exec), first, last, result, pstl::internal::equal_value(old_value), new_value);
-}
-
-// [alg.fill]
-
-template
-pstl::internal::enable_if_execution_policy
-fill( ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, const T& value ) {
- using namespace pstl::internal;
- pattern_fill(first, last, value,
- is_parallelization_preferred(exec),
- is_vectorization_preferred(exec));
-}
-
-template< class ExecutionPolicy, class ForwardIterator, class Size, class T>
-pstl::internal::enable_if_execution_policy
-fill_n( ExecutionPolicy&& exec, ForwardIterator first, Size count, const T& value ) {
- if(count <= 0)
- return first;
-
- using namespace pstl::internal;
- return pattern_fill_n(first, count, value,
- is_parallelization_preferred(exec),
- is_vectorization_preferred(exec));
-}
-
-// [alg.generate]
-template< class ExecutionPolicy, class ForwardIterator, class Generator>
-pstl::internal::enable_if_execution_policy
-generate( ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Generator g ) {
- using namespace pstl::internal;
- pattern_generate(first, last, g,
- is_parallelization_preferred(exec),
- is_vectorization_preferred(exec));
-}
-
-template< class ExecutionPolicy, class OutputIterator, class Size, class Generator>
-pstl::internal::enable_if_execution_policy
-generate_n( ExecutionPolicy&& exec, OutputIterator first, Size count, Generator g ) {
- if(count <= 0)
- return first;
-
- using namespace pstl::internal;
- return pattern_generate_n(first, count, g,
- is_parallelization_preferred(exec),
- is_vectorization_preferred(exec));
-}
-
-// [alg.remove]
-
-template
-pstl::internal::enable_if_execution_policy
-remove_copy_if(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result, Predicate pred) {
- return copy_if( std::forward(exec), first, last, result, pstl::internal::not_pred(pred));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-remove_copy(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result, const T& value) {
- return copy_if( std::forward(exec), first, last, result, pstl::internal::not_equal_value(value));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-remove_if(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, UnaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_remove_if(first, last, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-remove(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, const T& value) {
- return remove_if(std::forward(exec), first, last, pstl::internal::equal_value(value));
-}
-
-// [alg.unique]
-
-template
-pstl::internal::enable_if_execution_policy
-unique(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, BinaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_unique(first, last, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-unique(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last) {
- return unique(std::forward(exec), first, last, pstl::internal::pstl_equal());
-}
-
-template
-pstl::internal::enable_if_execution_policy
-unique_copy(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result, BinaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_unique_copy(first, last, result, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-unique_copy(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result) {
- return unique_copy(std::forward(exec), first, last, result, pstl::internal::pstl_equal() );
-}
-
-// [alg.reverse]
-
-template
-pstl::internal::enable_if_execution_policy
-reverse(ExecutionPolicy&& exec, BidirectionalIterator first, BidirectionalIterator last) {
- using namespace pstl::internal;
- pattern_reverse(first, last,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-reverse_copy(ExecutionPolicy&& exec, BidirectionalIterator first, BidirectionalIterator last, ForwardIterator d_first) {
- using namespace pstl::internal;
- return pattern_reverse_copy(first, last, d_first,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-// [alg.rotate]
-
-template
-pstl::internal::enable_if_execution_policy
-rotate(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator middle, ForwardIterator last) {
- using namespace pstl::internal;
- return pattern_rotate(first, middle, last,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-rotate_copy(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 middle, ForwardIterator1 last, ForwardIterator2 result) {
- using namespace pstl::internal;
- return pattern_rotate_copy(first, middle, last, result,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-// [alg.partitions]
-
-template
-pstl::internal::enable_if_execution_policy
-is_partitioned(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, UnaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_is_partitioned(first, last, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-partition(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, UnaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_partition(first, last, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-stable_partition(ExecutionPolicy&& exec, BidirectionalIterator first, BidirectionalIterator last, UnaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_stable_partition(first, last, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy>
-partition_copy(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, ForwardIterator1 out_true, ForwardIterator2 out_false, UnaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_partition_copy(first, last, out_true, out_false, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-// [alg.sort]
-
-template
-pstl::internal::enable_if_execution_policy
-sort(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator last, Compare comp) {
- typedef typename iterator_traits::value_type input_type;
- using namespace pstl::internal;
- return pattern_sort(first, last, comp,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec),
- typename std::is_move_constructible::type());
-}
-
-template
-pstl::internal::enable_if_execution_policy
-sort(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator last) {
- typedef typename iterator_traits::value_type input_type;
- sort(std::forward(exec), first, last, std::less());
-}
-
-// [stable.sort]
-
-template
-pstl::internal::enable_if_execution_policy
-stable_sort(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator last, Compare comp) {
- using namespace pstl::internal;
- return pattern_stable_sort(first, last, comp,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-stable_sort(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator last) {
- typedef typename iterator_traits::value_type input_type;
- stable_sort(std::forward(exec), first, last, std::less());
-}
-
-// [mismatch]
-
-template< class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class BinaryPredicate >
-pstl::internal::enable_if_execution_policy>
-mismatch(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred) {
- using namespace pstl::internal;
- return pattern_mismatch(first1, last1, first2, last2, pred,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template< class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class BinaryPredicate >
-pstl::internal::enable_if_execution_policy>
-mismatch(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, BinaryPredicate pred) {
- return mismatch(std::forward(exec), first1, last1, first2, std::next(first2, std::distance(first1, last1)), pred);
-}
-
-template< class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2 >
-pstl::internal::enable_if_execution_policy>
-mismatch(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2) {
- return mismatch(std::forward(exec), first1, last1, first2, last2, pstl::internal::pstl_equal());
-}
-
-template< class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2 >
-pstl::internal::enable_if_execution_policy>
-mismatch(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2) {
- return mismatch(std::forward(exec), first1, last1, first2, std::next(first2, std::distance(first1, last1)));
-}
-
-// [alg.equal]
-
-template
-pstl::internal::enable_if_execution_policy
-equal(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, BinaryPredicate p) {
- using namespace pstl::internal;
- return pattern_equal(first1, last1, first2, p,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec)
- );
-}
-
-template
-pstl::internal::enable_if_execution_policy
-equal(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2) {
- return equal(std::forward(exec), first1, last1, first2, pstl::internal::pstl_equal());
-}
-
-template
-pstl::internal::enable_if_execution_policy
-equal(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate p) {
- if ( std::distance(first1, last1) == std::distance(first2, last2) )
- return std::equal(std::forward(exec), first1, last1, first2, p);
- else
- return false;
-}
-
-template
-pstl::internal::enable_if_execution_policy
-equal(ExecutionPolicy&& exec, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2) {
- return equal(std::forward(exec), first1, last1, first2, pstl::internal::pstl_equal());
-}
-
-// [alg.move]
-template< class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2 >
-pstl::internal::enable_if_execution_policy
-move(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 d_first) {
- using namespace pstl::internal;
- const auto is_vector = is_vectorization_preferred(exec);
-
- return pattern_walk2_brick(first, last, d_first, [is_vector](ForwardIterator1 begin, ForwardIterator1 end, ForwardIterator2 res) {
- return brick_move(begin, end, res, is_vector);
- }, is_parallelization_preferred(exec));
-}
-
-// [partial.sort]
-
-template
-pstl::internal::enable_if_execution_policy
-partial_sort(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp) {
- using namespace pstl::internal;
- pattern_partial_sort(first, middle, last, comp,
- is_vectorization_preferred(exec),
- is_parallelization_preferred(exec));
-}
-
-template
-pstl::internal::enable_if_execution_policy
-partial_sort(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last) {
- typedef typename iterator_traits::value_type input_type;
- partial_sort(exec, first, middle, last, std::less