template <typename... Ts>
struct A
{
template <typename C>
constexpr auto proc() noexcept { return C{ }; }
constexpr size_t size() noexcept { return sizeof...(Ts); }
};
template <typename... Ts>
struct B : public A<Ts...>
{
using base_t = A<Ts...>;
template <typename... Cs>
constexpr auto example_prog_1() noexcept
{
constexpr size_t tmp = base_t::size();
// error C2131 : its not constexpr
return tmp + sizeof...(Cs);
}
template <typename... Cs>
constexpr auto example_prog_0() noexcept
{
return example_prog_1<decltype(base_t::template proc<Cs>())...>();
}
};
int main()
{
B<int, int, int, int> obj0 { };
constexpr size_t result0 = obj0.example_prog_0<char, char, char, char>();
}
this not work. i got error C2131 : Expression did not evaluate to a constant.
template <typename... Cs>
constexpr auto example_prog_1() noexcept
{
B dup{ };
constexpr size_t tmp = dup.size();
// error none : its fine
return tmp + sizeof...(Cs);
}
but making copy its fine.
it also working when add 'this auto self' and using it.
could someone tell me why ? (msvc /std:c++latest)