1#ifndef _BBM_ATTRIBUTE_H_
2#define _BBM_ATTRIBUTE_H_
39 using type =
typename PROP::type;
54 template<
typename... U>
requires ((
sizeof...(U) != 1) || (!
concepts::attribute<U> && ...)) &&
requires(U&&... u) {{ type(std::forward<U>(u)...)};}
58 template<
typename TYPE>
requires std::constructible_from<TYPE, type>
59 explicit inline operator TYPE(
void)
const {
return TYPE(
type(*
this)); }
61 inline operator type&(void) {
return *
this; }
62 inline operator const type&(void)
const {
return *
this; }
65 inline const type&
value(
void)
const {
return *
this; }
72 inline decltype(
auto) operator->(void) {
return type::operator->(); }
73 inline decltype(
auto) operator->(void)
const {
return type::operator->(); }
75 template<
typename S>
inline decltype(
auto) operator->*(S s) {
return type::operator->*(s); }
76 template<
typename S>
inline decltype(
auto) operator->*(S s)
const {
return type::operator->*(s); }
96 template<
typename PROP>
requires (concepts::attribute_property<PROP> && std::is_scalar_v<typename PROP::type>)
97 struct attribute<PROP>
99 using type =
typename PROP::type;
117 template<
typename TYPE>
requires std::constructible_from<TYPE,type>
118 explicit inline operator TYPE(
void)
const {
return TYPE(_value); }
120 inline operator type&(void) {
return _value; }
121 inline operator const type&(void)
const {
return _value; }
131 inline decltype(
auto) operator->(void) {
return _value; }
132 inline decltype(
auto) operator->(void)
const {
return _value; }
134 template<
typename S>
inline decltype(
auto) operator->*(S s) {
return _value->*(s); }
135 template<
typename S>
inline decltype(
auto) operator->*(S s)
const {
return _value->*(s); }
155#define BBM_ATTR_POST(OP) template<typename U, typename P> requires std::is_scalar_v<U> inline constexpr auto operator OP (U&& u, const attribute<P>& a) { return (std::forward<U>(u) OP a.value()); }
Helper methods for extracting the value of an attribute (according to concepts::attribute).
attribute_property concept
Definition: attribute.h:22
attribute concept
Definition: attribute.h:39
convertible concept
Definition: convertible.h:15
attribute and attribute_property contracts
#define BBM_ATTR_POST(OP)
Definition: attribute.h:155
Convert a string to an object and vice versa.
Definition: aggregatebsdf.h:29
std::string toString(const T &)
toString alias
Definition: stringconvert.h:594
decltype(auto) value(T &&t)
return the value of an attribute, or if not an attribute the object
Definition: attribute_value.h:20
Base declaration of attribute; further specialized below.
Definition: attribute.h:26
attribute & operator=(const T &t)
Assignment operator.
Definition: attribute.h:69
attribute(U &&... u)
Forward constructor.
Definition: attribute.h:55
std::string toString(void) const
Custom toString.
Definition: attribute.h:80
PROP prop
Definition: attribute.h:40
typename PROP::type type
Definition: attribute.h:39
type _value
Definition: attribute.h:145
attribute(const T &t)
Copy Constructor.
Definition: attribute.h:47
const type & value(void) const
Definition: attribute.h:65
type & value(void)
Definition: attribute.h:64
attribute(const type &t)
Value constructor.
Definition: attribute.h:106
static attribute fromString(const std::string &str)
Custom fromString.
Definition: attribute.h:83
attribute(void)=default
Default construstor.