Date: Fri, 28 Jan 2022 09:22:44 -0300
If the template instantiation depends on an incomplete type, will two
consecutive calls use the same template instantiation even if the type
changed ?
template<typename T>
struct has_members_with_an_a {
constexpr static int value = /* some wizardry to get number of members
of T with an 'a' in the name*/ ; (1)
};
struct X {
int a;
constexpr static int sz = refl< X >::value; // sz == 1; (2)
int another; // adding some new
constexpr static int sz2 = refl< X >::value; // sz still == 1 (3)
};
Q1.) Does the template has_members_with_an_a "freezes" between calls, since
X will lead to the same Type ? In (3) we already have a "
has_members_with_an_a<X>" instantiated ?
Q2.) It also happens if we change (2) and (3) to call using ^X instead of
X ?
template<auto RT>
struct has_members_with_an_a {
constexpr static bool value = /* some wizardry to get the number of
members of RT with an 'a' in the name*/ ;
};
struct X {
int a;
constexpr static int sz = refl< ^X >::value; // sz == 1; (4)
int another; // adding some new
constexpr static int sz2 = refl< ^X >::value; // sz still == 1 (5)
};
Because we already have an instance of has_members_with_an_a<^X> with the
same "underlying int-ish value of ^X" ?
Q3.) Even if we change (1) to use consteval, still (2) == (3) ?
template<auto RT>
struct has_members_with_an_a {
consteval int value() { /* some wizardry to get the members of members
of RT with an 'a' in the name*/ ; (6) }
};
Cleiton
consecutive calls use the same template instantiation even if the type
changed ?
template<typename T>
struct has_members_with_an_a {
constexpr static int value = /* some wizardry to get number of members
of T with an 'a' in the name*/ ; (1)
};
struct X {
int a;
constexpr static int sz = refl< X >::value; // sz == 1; (2)
int another; // adding some new
constexpr static int sz2 = refl< X >::value; // sz still == 1 (3)
};
Q1.) Does the template has_members_with_an_a "freezes" between calls, since
X will lead to the same Type ? In (3) we already have a "
has_members_with_an_a<X>" instantiated ?
Q2.) It also happens if we change (2) and (3) to call using ^X instead of
X ?
template<auto RT>
struct has_members_with_an_a {
constexpr static bool value = /* some wizardry to get the number of
members of RT with an 'a' in the name*/ ;
};
struct X {
int a;
constexpr static int sz = refl< ^X >::value; // sz == 1; (4)
int another; // adding some new
constexpr static int sz2 = refl< ^X >::value; // sz still == 1 (5)
};
Because we already have an instance of has_members_with_an_a<^X> with the
same "underlying int-ish value of ^X" ?
Q3.) Even if we change (1) to use consteval, still (2) == (3) ?
template<auto RT>
struct has_members_with_an_a {
consteval int value() { /* some wizardry to get the members of members
of RT with an 'a' in the name*/ ; (6) }
};
Cleiton
Received on 2022-01-28 12:22:56