di 0.1.0
Loading...
Searching...
No Matches
value.h
Go to the documentation of this file.
1#pragma once
2
4#include "di/meta/util.h"
5#include "di/types/prelude.h"
6#include "di/util/forward.h"
7#include "di/util/move.h"
8
9namespace di::function {
10namespace detail {
11 template<typename T>
12 struct Value : pipeline::EnablePipeline {
13 public:
14 template<typename U>
15 constexpr explicit Value(InPlace, U&& value) : m_value(util::forward<U>(value)) {}
16
17 constexpr auto operator()(auto&&...) & -> T& { return m_value; }
18 constexpr auto operator()(auto&&...) const& -> T const& { return m_value; }
19 constexpr auto operator()(auto&&...) && -> T&& { return util::move(m_value); }
20 constexpr auto operator()(auto&&...) const&& -> T const&& { return util::move(m_value); }
21
22 private:
23 T m_value;
24 };
25
26 struct ValueFunction : pipeline::EnablePipeline {
27 template<concepts::DecayConstructible T>
28 constexpr auto operator()(T&& value) const {
29 return Value<meta::Decay<T>> { in_place, util::forward<T>(value) };
30 }
31 };
32}
33
34constexpr inline auto value = detail::ValueFunction {};
35}
Definition as_bool.h:8
constexpr auto value
Definition value.h:34
constexpr auto in_place
Definition in_place.h:8