Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About template specialization (substitute, define_aggregate) #118

Open
Pespon opened this issue Nov 22, 2024 · 0 comments
Open

About template specialization (substitute, define_aggregate) #118

Pespon opened this issue Nov 22, 2024 · 0 comments

Comments

@Pespon
Copy link

Pespon commented Nov 22, 2024

Hi

I've been experimenting with p2996, and have encountered use cases for which I don't understand the behavior, and would appreciate a helping hand.

Use cases
Considering the following template:

template<int n>
struct generated_template_test;

Case *1:
If I specialize it in the root namespace via:

template<>
struct generated_template_test<42> {};

I observe that the return value of members_of(^::).size() increments by 1, which is what I expected.

Case *2:
On the other hand, if I do the specialization like this (in the root namespace):
static_assert(is_type(define_aggregate(substitute(^generated_template_test, {std::meta::reflect_value(42)}), {})));

I observe that the return value of members_of(^::).size() does not change, which I find strange, whereas the specialized version of template can be instantiated perfectly well.

Case *3:
Furthermore, if I specialize the template in a namespace (also works with a class):

namespace a_namespace
{
    static_assert(is_type(define_aggregate(substitute(^generated_template_test, {std::meta::reflect_value(42)}), {}))));
}

The situation seems to be perfectly similar to *2.

Questions
This raises the following questions:
A/ Is case *3 allowed (class specialization in a namespace)?
B/ Is it normal for the return of members_of(^::).size() and members_of(^a_namespace).size() not to change once the template has been specialized?
C/ Is there a way to browse all the specializations of a template class?

Thank you for your time, I really appreciate your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant