7#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_FUNCTIONAL_BIND_OVERLOADS_HPP_
8#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_FUNCTIONAL_BIND_OVERLOADS_HPP_
14#include "arene/base/stdlib_choice/decay.hpp"
15#include "arene/base/stdlib_choice/forward.hpp"
16#include "arene/base/stdlib_choice/is_constructible.hpp"
17#include "arene/base/stdlib_choice/is_copy_constructible.hpp"
18#include "arene/base/stdlib_choice/is_move_constructible.hpp"
19#include "arene/base/stdlib_choice/move.hpp"
25namespace bind_overloads_detail {
31template <
typename... OverloadTs>
32class bind_overloads_impl;
37template <
typename OverloadT>
38class bind_overloads_impl<OverloadT> : OverloadT {
43 : OverloadT(overload) {}
48 : OverloadT(std::
move(overload)) {}
51 ~bind_overloads_impl() =
default;
54 using OverloadT::operator();
58 constexpr bind_overloads_impl(bind_overloads_impl
const&
copy) =
default;
60 constexpr bind_overloads_impl(bind_overloads_impl&&
move) =
default;
62 constexpr auto operator=(bind_overloads_impl
const&
copy) -> bind_overloads_impl& =
default;
64 constexpr auto operator=(bind_overloads_impl&&
move) -> bind_overloads_impl& =
default;
72template <
typename OverloadT,
typename... OverloadTs>
73class bind_overloads_impl<OverloadT, OverloadTs...>
75 , bind_overloads_impl<OverloadTs...> {
81 template <
typename... UOverloads>
82 constexpr explicit bind_overloads_impl(OverloadT
const& overload, UOverloads&&... overloads)
noexcept(
84 std::is_nothrow_constructible<bind_overloads_impl<OverloadTs...>, UOverloads&&...>::value
86 : OverloadT(overload),
87 bind_overloads_impl<OverloadTs...>(std::
forward<UOverloads>(overloads)...) {}
93 template <
typename... UOverloadTs>
94 constexpr explicit bind_overloads_impl(OverloadT&& overload, UOverloadTs&&... overloads)
noexcept(
96 std::is_nothrow_constructible<bind_overloads_impl<OverloadTs...>, UOverloadTs&&...>::value
98 : OverloadT(std::
move(overload)),
99 bind_overloads_impl<OverloadTs...>(std::
forward<UOverloadTs>(overloads)...) {}
102 ~bind_overloads_impl() =
default;
105 using OverloadT::operator();
107 using bind_overloads_impl<OverloadTs...>::operator();
111 constexpr bind_overloads_impl(bind_overloads_impl
const&
copy) =
default;
113 constexpr bind_overloads_impl(bind_overloads_impl&&
move) =
default;
115 constexpr auto operator=(bind_overloads_impl
const&
copy) -> bind_overloads_impl& =
default;
117 constexpr auto operator=(bind_overloads_impl&&
move) -> bind_overloads_impl& =
default;
124template <
typename... OverloadTs>
125class bind_overloads_t : bind_overloads_impl<OverloadTs...> {
128 using bind_overloads_impl<OverloadTs...>::bind_overloads_impl;
130 using bind_overloads_impl<OverloadTs...>::operator();
148template <
typename... OverloadsT>
151 bind_overloads_detail::bind_overloads_t<std::decay_t<OverloadsT>...>,
152 OverloadsT&&...>::value
154 return bind_overloads_detail::bind_overloads_t<std::decay_t<OverloadsT>...>{
std::forward<OverloadsT>(overloads)...};
static constexpr value_type value
Definition integral_constant.hpp:34
Type trait to detect if a type is constructible from arguments of the specified types and is noexcept...
Definition is_constructible.hpp:84
Definition accumulate.hpp:37
constexpr auto move(InIterator first, InIterator last, OutIterator output) noexcept(noexcept(*first++) &&noexcept(output++) &&//CODEQLFP(EXP52-CPP) CODEQLFP(A5-2-6) noexcept(first !=last) &&//CODEQLFP(A5-2-6) std::is_nothrow_assignable<, typename std::iterator_traits< InIterator >::value_type >::value) -> OutIterator
Moves the elements in the range [first, last), to another range beginning at output,...
Definition move.hpp:46
constexpr auto copy(InputIterator first, InputIterator last, OutputIterator output) noexcept(noexcept(*(++output)) &&noexcept(*(++first)) &&noexcept(first !=last) &&std::is_nothrow_assignable<, typename std::iterator_traits< InputIterator >::reference >::value) -> OutputIterator
Copies the elements in the range, defined by [first, last), to another range beginning at output.
Definition copy.hpp:40
constexpr auto bind_overloads(OverloadsT &&... overloads) noexcept(std::is_nothrow_constructible< bind_overloads_detail::bind_overloads_t< std::decay_t< OverloadsT >... >, OverloadsT &&... >::value) -> bind_overloads_detail::bind_overloads_t< std::decay_t< OverloadsT >... >
Given a sequence of invocables, creates a type which is the sum-type of all the input invocables.
Definition bind_overloads.hpp:149
Definition accumulate.hpp:36
typename decay< Type >::type decay_t
A conversion equivalent to those performed when passing function arguments by value.
Definition decay.hpp:48
constexpr auto forward(remove_reference_t< T > &value) noexcept -> T &&
Cast a value to an rvalue if T is an rvalue or rvalue reference, otherwise forward an lvalue referenc...
Definition forward.hpp:24