19namespace pw::multibuf::v2 {
54constexpr bool PropertiesAreInOrderWithoutDuplicates() {
58constexpr bool PropertiesAreInOrderWithoutDuplicates() {
59 return (kLhs < kRhs) &&
60 PropertiesAreInOrderWithoutDuplicates<kRhs, kOthers...>();
66constexpr bool PropertiesAreValid() {
67 if constexpr (
sizeof...(kProperties) != 0) {
68 static_assert(PropertiesAreInOrderWithoutDuplicates<kProperties...>(),
69 "Properties must be specified in the following order, "
70 "without duplicates: kConst, kLayerable, kObservable");
90template <
typename From,
typename To>
91using EnableIfConvertible =
92 std::enable_if_t<std::is_same_v<To, GenericMultiBuf> ||
96 (!From::is_const() || To::is_const()) &&
98 (From::is_layerable() || !To::is_layerable()) &&
101 (From::is_observable() || !To::is_observable()))>;
106template <
typename From,
typename To>
107static constexpr void AssertIsConvertibleIgnoreConst() {
108 if constexpr (!std::is_same_v<To, GenericMultiBuf>) {
110 "Only conversion to other MultiBuf types are supported.");
111 static_assert(From::is_layerable() || !To::is_layerable(),
112 "Flat MultiBufs do not have layer-related methods.");
113 static_assert(From::is_observable() || !To::is_observable(),
114 "Untracked MultiBufs do not have observer-related methods.");
123template <
typename From,
typename To>
124static constexpr void AssertIsConvertible() {
125 if constexpr (!std::is_same_v<To, GenericMultiBuf>) {
126 AssertIsConvertibleIgnoreConst<From, To>();
127 static_assert(!From::is_const() || To::is_const(),
128 "Read-only data cannot be converted to mutable data.");
139template <
typename From,
typename To>
140static constexpr void AssertIsAssignable() {
141 if constexpr (!std::is_same_v<To, GenericMultiBuf>) {
142 static_assert(IsBasicMultiBuf<To>::value,
143 "Only assignment to other MultiBuf types are supported.");
144 static_assert(!From::is_const() || To::is_const(),
145 "Read-only data cannot be assigned to mutable data.");
146 static_assert(!From::is_layerable() || To::is_layerable(),
147 "Layered MultiBufs cannot be assigned to flat MultiBufs.");
149 !From::is_observable() || To::is_observable(),
150 "Tracked MultiBufs cannot be assigned to untracked MultiBufs.");
Definition: multibuf.h:194
Property
Basic properties of a MultiBuf.
Definition: properties.h:24
Type trait to identify MultiBuf types.
Definition: properties.h:77