for each X instantiation.
[[ my_attr1{} ]] template<typename T> [[
my_attr2<T>{} ]] struct X {};
X<int> x_int ;
X<float>
x_float;
so, if we ask for "attributes_of(
type_of(^x_int) )", it should be expanded as
constexpr auto temp1 =
my_attr1{};
constexpr auto temp2 =
my_attr2<int>{};
attributes_of( type_of(^x_int) ) == { ^temp1, ^temp2 };
constexpr auto temp3 =
my_attr2<float>();
attributes_of( type_of(^x_float) ) == { ^temp1, ^temp3 };
instead of
attributes_of( type_of(^x_int) ) == { my_attr1{} , my_attr2<int>{} };
attributes_of( type_of(^x_float) ) == { my_attr1{} , my_attr2<
float >{} };
so, subsequent calls to attributes_of( type_of(^x_int) ) would not construct other instances of
my_attr1 /
my_attr2 , right ?
2 - What if my_attr3 does not depend on T ?. Well the same, one my_attr3 to each instance
[[
my_attr1{} ]] template<typename T> [[
my_attr3{ constexpr_foo_counter() } ]] struct X {};
X<int> x_int ;
constexpr auto temp1 = my_attr1{};
constexpr auto temp2 = my_attr3{ constexpr_foo_counter() };
attributes_of( type_of(^x_int) ) == { ^temp1, ^temp2 };
constexpr auto temp3 =
my_attr3{ constexpr_foo_counter() }; // calling again possibly with different result
attributes_of( type_of(^x_float) ) == { ^temp1, ^temp3 };
3 - Would it be possible to get the instance of my_attr1, without instantiation of X, also be possible to get the template name "my_attr2" without instantiating X, just reflecting the template ( not a particular instance )
[[
my_attr1{} ]] template<typename T> [[
my_attr2<T>{} ]] struct X {};
constexpr auto temp1 =
my_attr1{};
attributes_of( ^X ) == { ^temp1, ^my_attr2 };
4 - Specializations should forget all previous attributes.
template<> [[
my_attr4{} ]] struct X<void> {} x_void;
constexpr auto temp1 = my_attr4{};
attributes_of( type_of(^x_void ) ) == { ^temp1 };
Since one can get the "parent" attributes from de template declaration
attributes_of( template_of( type_of(^x_void ) ) ) == attributes_of( ^X );
5 - All standard attributes must belong to a std:: namespace, avoiding conflict in future proposals.
Thanks