siplasplas
A library for C++ reflection and introspection
Algorithm

Constexpr counterparts of some standard algorithms. More...

Classes

struct  cpp::constexp::Equal
 Constexpr functor that compares two values for equality. More...
 
struct  cpp::constexp::NotEqual
 Constexpr functor that compares two values for inequality. More...
 

Functions

template<typename Sequence >
constexpr auto cpp::constexp::begin (const Sequence &sequence)
 Returns an iterator pointing to the beginning of a sequence. More...
 
template<typename T , std::size_t N>
constexpr auto cpp::constexp::begin (const T(&array)[N])
 Returns an iterator pointing to the beginning of an array. More...
 
template<typename Sequence >
constexpr auto cpp::constexp::end (const Sequence &sequence)
 Returns an iterator pointing to the end of a sequence. More...
 
template<typename T , std::size_t N>
constexpr auto cpp::constexp::end (const T(&array)[N])
 Returns an iterator pointing to the end of an array. More...
 
template<typename Begin , typename End >
constexpr auto cpp::constexp::distance (Begin begin, End end)
 Returns the distance between two iterators.
 
template<typename Begin1 , typename End1 , typename Begin2 , typename End2 , typename Compare >
constexpr bool cpp::constexp::equal (Begin1 begin1, End1 end1, Begin2 begin2, End2 end2, Compare compare)
 Compares if two sequences are equal. More...
 
template<typename Begin1 , typename End1 , typename Begin2 , typename End2 >
constexpr bool cpp::constexp::equal (Begin1 begin1, End1 end1, Begin2 begin2, End2 end2)
 Compares if two sequences are equal. More...
 
template<typename Lhs , typename Rhs >
constexpr bool cpp::constexp::equal (const Lhs &lhs, const Rhs &rhs)
 Compares if two sequences are equal. More...
 
template<typename T >
constexpr const T & cpp::constexp::max (const T &lhs, const T &rhs)
 Returns the greatest value of the two given. More...
 
template<typename T , typename U >
constexpr std::common_type_t< T, U > cpp::constexp::max (const T &lhs, const U &rhs)
 Returns the greatest value of the two given. More...
 
template<typename First , typename Second , typename Third , typename... Tail>
decltype(auto) constexpr cpp::constexp::max (const First &first, const Second &second, const Third &third, const Tail &... tail)
 Returns the greatest value of the set of values given.
 
template<typename T >
constexpr const T & cpp::constexp::min (const T &lhs, const T &rhs)
 Returns the smallest value of the two given. More...
 
template<typename T , typename U >
constexpr std::common_type_t< T, U > cpp::constexp::min (const T &lhs, const U &rhs)
 Returns the smallest value of the two given. More...
 
template<typename First , typename Second , typename Third , typename... Tail>
decltype(auto) constexpr cpp::constexp::min (const First &first, const Second &second, const Third &third, const Tail &... tail)
 Returns the smallest value of the set of values given.
 
template<typename Begin1 , typename End1 , typename Begin2 , typename End2 >
constexpr std::size_t cpp::constexp::levenshteinDistance (Begin1 begin1, End1 end1, Begin2 begin2, End2 end2)
 Computes the distance between two sequences using the Levenshtein distance algorithm.
 
template<typename Lhs , typename Rhs >
constexpr std::size_t cpp::constexp::levenshteinDistance (const Lhs &lhs, const Rhs &rhs)
 Computes the distance between two sequences using the Levenshtein distance algorithm.
 
template<typename Iterator , typename T >
constexpr Iterator cpp::constexp::find (Iterator begin, Iterator end, const T &value)
 Finds a value in a sequence. More...
 

Detailed Description

Constexpr counterparts of some standard algorithms.

Function Documentation

§ begin() [1/2]

template<typename Sequence >
constexpr auto cpp::constexp::begin ( const Sequence &  sequence)

Returns an iterator pointing to the beginning of a sequence.

Returns
An iterator pointing to the first element of a sequence. Invokes sequence.begin().

§ begin() [2/2]

template<typename T , std::size_t N>
constexpr auto cpp::constexp::begin ( const T(&)  array[N])

Returns an iterator pointing to the beginning of an array.

Returns
An iterator pointing to the first element of the array Returns &array[0].

§ end() [1/2]

template<typename Sequence >
constexpr auto cpp::constexp::end ( const Sequence &  sequence)

Returns an iterator pointing to the end of a sequence.

Returns
An iterator pointing to the past the end element of a sequence. Invokes sequence.end().

§ end() [2/2]

template<typename T , std::size_t N>
constexpr auto cpp::constexp::end ( const T(&)  array[N])

Returns an iterator pointing to the end of an array.

Returns
An iterator pointing to the past the end element of the array Returns &array[N].

§ equal() [1/3]

template<typename Begin1 , typename End1 , typename Begin2 , typename End2 , typename Compare >
constexpr bool cpp::constexp::equal ( Begin1  begin1,
End1  end1,
Begin2  begin2,
End2  end2,
Compare  compare 
)

Compares if two sequences are equal.

Parameters
begin1Iterator to the beginning of the first sequence
end1Iterator to the end of the first sequence
begin2Iterator to the beginning of the second sequence
end2Iterator to the end of the second sequence
compareComparison predicate of signature bool(Type1, Type2) The behavior is undefined if the predicate modifies the elements passed to it

This function performs a constexpr equality comparison of two sequences. The constexpr-ness of the function is not guaranteed and depends on the given comparison predicate and the iterators.

Returns
True if the two sequences are of the same length and their elements are equal. False otherwise

§ equal() [2/3]

template<typename Begin1 , typename End1 , typename Begin2 , typename End2 >
constexpr bool cpp::constexp::equal ( Begin1  begin1,
End1  end1,
Begin2  begin2,
End2  end2 
)

Compares if two sequences are equal.

Parameters
begin1Iterator to the beginning of the first sequence
end1Iterator to the end of the first sequence
begin2Iterator to the beginning of the second sequence
end2Iterator to the end of the second sequence

This function performs a constexpr equality comparison of two sequences. The constexpr-ness of the function is not guaranteed and depends on the given iterators. The function uses cpp::Equal constexpr functor for comparison

Returns
True if the two sequences are of the same length and their elements are equal. False otherwise

§ equal() [3/3]

template<typename Lhs , typename Rhs >
constexpr bool cpp::constexp::equal ( const Lhs &  lhs,
const Rhs &  rhs 
)

Compares if two sequences are equal.

Parameters
lhsFirst sequence
rhsSecond sequence
Returns
True if the two sequences are of the same length and their elements are equal. False otherwise

§ find()

template<typename Iterator , typename T >
constexpr Iterator cpp::constexp::find ( Iterator  begin,
Iterator  end,
const T &  value 
)

Finds a value in a sequence.

Parameters
beginIterator pointing to the first element of the sequence
endIterator pointing to past-the-end element of the sequence
valueValue to compare elements to
Returns
Iterator to the first element equal to the given value, end if not found.

§ max() [1/2]

template<typename T >
constexpr const T& cpp::constexp::max ( const T &  lhs,
const T &  rhs 
)

Returns the greatest value of the two given.

Returns
lhs if lhs is bigger or equal than rhs. rhs otherwise.

§ max() [2/2]

template<typename T , typename U >
constexpr std::common_type_t<T, U> cpp::constexp::max ( const T &  lhs,
const U &  rhs 
)

Returns the greatest value of the two given.

Returns
lhs if lhs is bigger or equal than rhs. rhs otherwise.

§ min() [1/2]

template<typename T >
constexpr const T& cpp::constexp::min ( const T &  lhs,
const T &  rhs 
)

Returns the smallest value of the two given.

Returns
lhs if lhs is less or equal than rhs. rhs otherwise.

§ min() [2/2]

template<typename T , typename U >
constexpr std::common_type_t<T, U> cpp::constexp::min ( const T &  lhs,
const U &  rhs 
)

Returns the smallest value of the two given.

Returns
lhs if lhs is less or equal than rhs. rhs otherwise.