14 template <copy_constructible_
object T>
23 noexcept(std::is_nothrow_default_constructible_v<T>)
24 requires std::default_initializable<T>
25 : instance_(std::in_place) {}
27 template <
class U = T>
28 requires std::constructible_from<T, U&&>
30 noexcept(std::is_nothrow_constructible_v<T, U&&>)
31 : instance_(std::in_place, std::forward<U>(u)) {}
33 constexpr const T& operator*()
const&
noexcept {
36 constexpr const T&& operator*()
const&&
noexcept {
37 return std::move(*instance_);
39 constexpr T& operator*() &
noexcept {
42 constexpr T&& operator*() &&
noexcept {
43 return std::move(*instance_);
46 constexpr const T* operator->()
const noexcept {
47 return instance_.operator->();
49 constexpr T* operator->()
noexcept {
50 return instance_.operator->();
61 template <copy_constructible_
object T>
70 template <copy_constructible_
object U>
71 constexpr auto operator()(U&& u)
const {
77 template <is_Identity I>
78 constexpr auto operator()(I&& x)
const noexcept ->
decltype(*std::forward<I>(x)) {
79 return *std::forward<I>(x);
84 inline namespace cpo {
87 inline constexpr partial<detail::run_Identity_op> run_Identity{};
94 template <copy_constructible_
object T>
98 template <is_Identity I,
class F>
99 constexpr auto operator()(I&& x, F&& f)
const
100 noexcept(
noexcept(std::invoke(std::forward<F>(f), run_Identity % std::forward<I>(x))))
101 ->
decltype( std::invoke(std::forward<F>(f), run_Identity % std::forward<I>(x))) {
102 return std::invoke(std::forward<F>(f), run_Identity % std::forward<I>(x));
106 static constexpr bind_op
bind{};
109 template <copy_constructible_
object T>
113 template <
class F, is_Identity I>
114 constexpr auto operator()(F&& f, I&& x)
const
115 noexcept(
noexcept(make_Identity(std::invoke(std::forward<F>(f), run_Identity % std::forward<I>(x)))))
116 ->
decltype( make_Identity(std::invoke(std::forward<F>(f), run_Identity % std::forward<I>(x)))) {
117 return make_Identity(std::invoke(std::forward<F>(f), run_Identity % std::forward<I>(x)));
121 static constexpr fmap_op
fmap{};
125 template <copy_constructible_
object T>
127 static constexpr auto pure = make_Identity;
A partial specialization of copyable_box.
Definition: copyable_box.hpp:124
constexpr partial< detail::liftA2_op > liftA2
liftA2 :: (a -> b -> c) -> f a -> f b -> f c
Definition: applicative.hpp:173
constexpr auto discard2nd
discard2nd :: f a -> f b -> f a
Definition: applicative.hpp:182
constexpr partial< detail::fmap_op > fmap
fmap :: (a -> b) -> f a -> f b
Definition: applicative.hpp:161
constexpr partial< detail::liftA2_op > liftA2
liftA2 :: (a -> b -> c) -> f a -> f b -> f c
Definition: applicative.hpp:102
constexpr partial< detail::bind_op > bind
bind :: forall a b. m a -> (a -> m b) -> m b
Definition: monad.hpp:45
constexpr partial< detail::discard1st_op > discard1st
discard1st :: f a -> f b -> f b
Definition: applicative.hpp:108
constexpr partial< detail::replace2nd_op > replace2nd
replace2nd :: a -> f b -> f a
Definition: functor.hpp:53
constexpr partial< detail::discard2nd_op > discard2nd
discard2nd :: f a -> f b -> f a
Definition: applicative.hpp:105
constexpr partial< detail::seq_apply_op > seq_apply
seq_apply :: f (a -> b) -> f a -> f b
Definition: applicative.hpp:99
constexpr partial< detail::pure_op< F > > pure
pure :: a -> f a
Definition: applicative.hpp:96
constexpr auto replace2nd
replace2nd :: a -> f b -> f a
Definition: functor.hpp:65
constexpr partial< detail::discard1st_op > discard1st
discard1st :: f a -> f b -> f b
Definition: monad.hpp:109
constexpr partial< detail::seq_apply_op > seq_apply
seq_apply :: f (a -> b) -> f a -> f b
Definition: monad.hpp:106
newtype Identity a = Identity { runIdentity :: a }
Definition: identity.hpp:15
class Functor f => Applicative f where
Definition: applicative.hpp:18
Definition: identity.hpp:59
Definition: identity.hpp:69
Definition: identity.hpp:76
class Functor f where
Definition: functor.hpp:14
class Applicative m => Monad m where
Definition: monad.hpp:15
Implements a perfect-forwarding call wrapper.
Definition: partial.hpp:63