27 template<
typename Type,
string_literal Name,
typename Default=
void>
struct arg;
34 template<
typename T>
struct is_arg_impl : std::false_type {};
35 template<
typename T,
string_literal N,
typename D>
struct is_arg_impl<
arg<T,N,D>> : std::true_type {};
39 using is_arg = bbm::detail::is_arg_impl<std::decay_t<T>>;
52 template<
string_literal Name>
53 struct arg<void, Name, void>
59 template<
typename Type>
requires (!std::is_rvalue_reference_v<Type&&>)
60 inline constexpr decltype(
auto)
operator=(Type&& val)
66 template<
typename Type>
requires std::is_rvalue_reference_v<Type&&>
67 inline constexpr decltype(
auto)
operator=(Type&& val)
69 using rtype = std::add_lvalue_reference_t<std::add_const_t<Type>>;
78 template<
typename Type,
string_literal Name>
requires (!std::is_void_v<Type> && !std::is_reference_v<Type>)
81 template<
typename T,
string_literal N,
typename D>
friend struct arg;
86 inline constexpr arg(
void) =
delete;
87 inline constexpr arg(
const std::decay_t<type>& val) : _value(val) {};
89 template<
typename OtherType,
string_literal OtherName,
typename OtherDefault>
requires std::constructible_from<std::decay_t<type>, OtherType>
94 inline constexpr arg&
operator=(
const std::decay_t<type>& val) { _value = val;
return *
this; }
97 inline constexpr std::add_const_t<type>&
value(
void)
const {
return _value; }
98 inline constexpr type&
value(
void) {
return _value; }
109 template<
typename Type,
string_literal Name,
typename Default>
requires (!std::is_void_v<Type> && !std::is_reference_v<Type>) && std::invocable<Default>
112 template<
typename T,
string_literal N,
typename D>
friend struct arg;
117 inline constexpr arg(
void) : _value( Default()() ) {};
118 inline constexpr arg(
const std::decay_t<type>& val) : _value(val) {}
120 template<
typename OtherType,
string_literal OtherName,
typename OtherDefault>
requires std::constructible_from<std::decay_t<type>, OtherType>
125 inline constexpr arg&
operator=(
const std::decay_t<type>& val) { _value = val;
return *
this; }
128 inline constexpr std::add_const_t<type>&
value(
void)
const {
return _value; }
142 template<
typename Type,
string_literal Name>
requires (!std::is_void_v<Type> && std::is_reference_v<Type>)
145 template<
typename T,
string_literal N,
typename D>
friend struct arg;
150 inline constexpr arg(
void) =
delete;
151 template<
typename OtherType,
string_literal OtherName,
typename OtherDefault>
requires std::constructible_from<bbm::persistent_reference<type>, OtherType>
154 template<
typename T>
requires (!is_arg_v<T> && std::constructible_from<bbm::persistent_reference<type>, T&&>)
155 inline constexpr arg(T&& val) : _value(std::forward<T>(val)) {};
162 _value.reassign( std::forward<T>(src) );
167 inline constexpr type value(
void)
const {
return _value; }
181 template<
typename Type,
string_literal Name,
typename Default>
requires (!std::is_void_v<Type> && std::is_reference_v<Type>) && std::invocable<Default>
184 template<
typename T,
string_literal N,
typename D>
friend struct arg;
189 inline constexpr arg(
void) : _value( Default()() ) {}
191 template<
typename OtherType,
string_literal OtherName,
typename OtherDefault>
requires std::constructible_from<bbm::persistent_reference<type>, OtherType>
194 template<
typename T>
requires (!is_arg_v<T> && std::constructible_from<bbm::persistent_reference<type>, T&&>)
195 inline constexpr arg(T&& val) : _value(std::forward<T>(val)) {}
202 _value.reassign( std::forward<T>(src) );
207 inline constexpr type value(
void)
const {
return _value; }
219 template<
typename T, bbm::
string_literal N,
typename D>
223 if constexpr (!std::is_void_v<T>)
225 s << bbm::typestring<T>;
226 if constexpr (!N.empty)
231 if constexpr (!N.empty)
235 if constexpr (!std::is_void_v<T>)
239 if constexpr (!std::is_void_v<D>)
248 template<
string_literal NAME>
259#define ArgDef(value) decltype([](){return value; })
concept to check if a type has a valid string_converter.
Definition: aggregatebsdf.h:29
constexpr bool is_arg_v
Definition: arg.h:42
std::ostream & operator<<(std::ostream &s, const BSDF &bsdf)
Definition: bsdf_base.h:138
std::string toString(const T &)
toString alias
Definition: stringconvert.h:594
bbm::detail::is_arg_impl< std::decay_t< T > > is_arg
Definition: arg.h:39
Forward declaration of bbm::arg.
Definition: arg.h:27
Declaration of persistent_reference specialized below.
Definition: reference.h:100
Assignable reference with wrapper support for rvalues.
constexpr arg & operator=(T &&src)
Assignment.
Definition: arg.h:200
constexpr std::add_const_t< type > & value(void) const
Definition: arg.h:128
constexpr arg(const std::decay_t< type > &val)
Definition: arg.h:118
constexpr arg & operator=(const std::decay_t< type > &val)
Assignment.
Definition: arg.h:125
constexpr type value(void)
Definition: arg.h:208
constexpr type value(void) const
Definition: arg.h:207
constexpr arg(void)
Definition: arg.h:189
constexpr arg(const arg< OtherType, OtherName, OtherDefault > &a)
Definition: arg.h:192
constexpr arg(T &&val)
Definition: arg.h:195
Type type
Definition: arg.h:114
constexpr type & value(void)
Definition: arg.h:129
constexpr arg(const arg< OtherType, OtherName, OtherDefault > &src)
Definition: arg.h:121
bbm::persistent_reference< type > _value
Definition: arg.h:212
constexpr arg(void)
Definition: arg.h:117
std::decay_t< type > _value
Definition: arg.h:133
constexpr arg & operator=(T &&src)
Assignment.
Definition: arg.h:160
constexpr std::add_const_t< type > & value(void) const
Definition: arg.h:97
constexpr arg(const std::decay_t< type > &val)
Definition: arg.h:87
constexpr arg & operator=(const std::decay_t< type > &val)
Assignment.
Definition: arg.h:94
constexpr type value(void)
Definition: arg.h:168
constexpr type value(void) const
Definition: arg.h:167
constexpr arg(const arg< OtherType, OtherName, OtherDefault > &src)
Definition: arg.h:152
constexpr arg(void)=delete
constexpr arg(T &&val)
Definition: arg.h:155
Type type
Definition: arg.h:83
constexpr type & value(void)
Definition: arg.h:98
constexpr arg(const arg< OtherType, OtherName, OtherDefault > &src)
Definition: arg.h:90
bbm::persistent_reference< type > _value
Definition: arg.h:172
std::decay_t< type > _value
Definition: arg.h:102
void type
Definition: arg.h:56
constexpr decltype(auto) operator=(Type &&val)
Assignment of non-rvalue.
Definition: arg.h:60
Definition: string_literal.h:16
produce stringview of type name of a type. Avoids using typeid for GCC, MSVC, and CLANG....