* 5  Sorting and related operations 
    * 5.1  Requirements 
    * 5.2  Partitioning operations 
    * 5.3  Sorting operations 
    * 5.4  Binary search operations (on partitioned ranges) 
    * 5.5  Set operations (on sorted ranges) 
    * 5.6  Merge operations (on sorted ranges) 
    * 5.7  Heap operations 
    * 5.8  Minimum/maximum operations 
    * 5.9  Lexicographical comparison operations 
    * 5.10  Permutation operations 
  * 6  Numeric operations 
  * 7  Operations on uninitialized memory 
  * 8  Random number generation 
  * 9  C library 
  * 10  Defect reports 
  * 11  See also 

  
---  
  
###  [ Constrained algorithms ](/w/cpp/algorithm/ranges
"cpp/algorithm/ranges")

C++20 provides [ constrained ](/w/cpp/language/constraints
"cpp/language/constraints") versions of most algorithms in the namespace `
std::ranges ` . In these algorithms, a range can be specified as either an [
iterator ](/w/cpp/iterator/input_or_output_iterator "cpp/iterator/input or
output iterator") \- [ sentinel ](/w/cpp/iterator/sentinel_for
"cpp/iterator/sentinel for") pair or as a single [ ` range `
](/w/cpp/ranges/range "cpp/ranges/range") argument, and projections and
pointer-to-member callables are supported. Additionally, the [ return types
](/w/cpp/algorithm/ranges#Return_types "cpp/algorithm/ranges") of most
algorithms have been changed to return all potentially useful information
computed during the execution of the algorithm.

    
    
    [std::vector](http://en.cppreference.com/w/cpp/container/vector)<int> v {7, 1, 4, 0, -1};
    std::[ranges::sort](http://en.cppreference.com/w/cpp/ranges-algorithm-placeholder/sort)(v); // constrained algorithm

(since C++20)  
  
  

###  Execution policies

Most algorithms have overloads that accept execution policies. The standard library algorithms support several [ execution policies ](/w/cpp/algorithm/execution_policy_tag_t "cpp/algorithm/execution policy tag t") , and the library provides corresponding execution policy types and objects. Users may select an execution policy statically by invoking a parallel algorithm with an [ execution policy object ](/w/cpp/algorithm/execution_policy_tag "cpp/algorithm/execution policy tag") of the corresponding type.  Standard library implementations (but not the users) may define additional execution policies as an extension. The semantics of parallel algorithms invoked with an execution policy object of implementation-defined type is implementation-defined.  Parallel version of algorithms (except for  [ std::for_each ](/w/cpp/algorithm/for_each "cpp/algorithm/for each") and  [ std::for_each_n ](/w/cpp/algorithm/for_each_n "cpp/algorithm/for each n") ) are allowed to make arbitrary copies of elements from ranges, as long as both  [ std::  is_trivially_copy_constructible_v  ](http://en.cppreference.com/w/cpp/types/is_copy_constructible) < T  > and  [ std::  is_trivially_destructible_v  ](http://en.cppreference.com/w/cpp/types/is_destructible) < T  > are  true  , where ` T ` is the type of elements.  |  Defined in header ` [ <execution> ](/w/cpp/header/execution "cpp/header/execution") `  
---  
Defined in namespace ` std::execution `  
[ sequenced_policy  parallel_policy  parallel_unsequenced_policy  unsequenced_policy  ](/w/cpp/algorithm/execution_policy_tag_t "cpp/algorithm/execution policy tag t") (C++17)  (C++17)  (C++17)  (C++20)  |  execution policy types   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/algorithm/dsc_execution_policy_tag_t&action=edit)  
[ seq  par  par_unseq  unseq  ](/w/cpp/algorithm/execution_policy_tag "cpp/algorithm/execution policy tag") (C++17)  (C++17)  (C++17)  (C++20)  |  global execution policy objects   
(constant)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/algorithm/dsc_execution_policy_tag&action=edit)  
Defined in namespace ` std `  
[ is_execution_policy  ](/w/cpp/algorithm/is_execution_policy "cpp/algorithm/is execution policy") (C++17)  |  te