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

annotations_of should not instantiate class template specializations #108

Open
katzdm opened this issue Oct 28, 2024 · 0 comments
Open

annotations_of should not instantiate class template specializations #108

katzdm opened this issue Oct 28, 2024 · 0 comments
Labels
p2996-ext A behavior not part of P2996, but proposed for a related paper

Comments

@katzdm
Copy link
Collaborator

katzdm commented Oct 28, 2024

Calling annotations_of(^^Cls<int>) should not trigger an instantiation of Cls<int> - but note that the needle needs to be carefully threaded here, as the dependent annotation expressions do need to be instantiated and attached to the specialization's Decl. e.g.,

#include <experimental/meta>

template <class T>
struct [[=1]] C {
    consteval {
        if (sizeof(T) == 1) {
            annotate(^^C<T>, std::meta::reflect_value(42));
        }
    }
};

template <>
struct C<int> { };

static_assert(annotations_of(^^C<bool>).size() == 1);
static_assert(annotations_of(^^C<int>).size() == 0);

(godbolt)

@katzdm katzdm added the p2996-ext A behavior not part of P2996, but proposed for a related paper label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2996-ext A behavior not part of P2996, but proposed for a related paper
Projects
None yet
Development

No branches or pull requests

1 participant