Loading...
Searching...
No Matches
attribute.h
Go to the documentation of this file.
1#ifndef _BBM_ATTRIBUTE_CONCEPT_H_
2#define _BBM_ATTRIBUTE_CONCEPT_H_
3
4#include <utility>
5
6/************************************************************************/
7/*! \file attribute.h
8
9 \brief attribute and attribute_property contracts
10*************************************************************************/
11
12namespace bbm {
13 namespace concepts {
14
15 /******************************************************************/
16 /*! \brief attribute_property concept
17
18 Each attribute_property must at least contain a typedef named 'type'
19 that indicates the underlying attribute type.
20 *******************************************************************/
21 template<typename PROP>
22 concept attribute_property = requires
23 {
24 typename std::decay_t<PROP>::type;
25 };
26
27
28 /********************************************************************/
29 /*! \brief attribute concept
30
31 Each attribute provides the following:
32 + typename type : the underlying type
33 + typename prop : requires attribute_property
34 + convertible_to the underlying (reference) type
35 + auto value() : return the cast to a reference of the underlying type
36 + auto value() const : return the cast to a const reference of the underlying type
37 *********************************************************************/
38 template<typename T>
39 concept attribute = requires(std::decay_t<T>& attr)
40 {
41 //! \brief has a type typename
42 typename std::decay_t<T>::type;
43
44 //! \brief has prop typename that also meet concepts::attribute_property
46
47 //! @{ \name value methods
48 { attr.value() } -> std::same_as<typename std::decay_t<T>::type&>;
49 { std::as_const(attr).value() } -> std::same_as<const typename std::decay_t<T>::type&>;
50 //! @}
51
52 //! @{ \name cast
53 static_cast<typename std::decay_t<T>::type&>(attr);
54 static_cast<const typename std::decay_t<T>::type&>(attr);
55 //! @}
56 };
57
58
59 /********************************************************************/
60 /*! \brief has_attribute_property concept
61
62 Checks if a type is an attribute with a given property
63 *********************************************************************/
64 template<typename T, typename PROP>
65 concept has_attribute_property = attribute<T> && attribute_property<PROP> && std::same_as<PROP, typename std::decay_t<T>::prop>;
66
67 } // end concepts namespace
68} // end bbm namespace
69
70#endif /* _BBM_ATTRIBUTE_CONCEPT_H_ */
attribute_property concept
Definition: attribute.h:22
attribute concept
Definition: attribute.h:39
has_attribute_property concept
Definition: attribute.h:65
Definition: aggregatebsdf.h:29