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

Add support for accessing the phantom tag parameter #87

Open
gotnone opened this issue Dec 10, 2024 · 0 comments
Open

Add support for accessing the phantom tag parameter #87

gotnone opened this issue Dec 10, 2024 · 0 comments

Comments

@gotnone
Copy link

gotnone commented Dec 10, 2024

I was looking at the feasibility of using NamedType to create some strong lambdas.

See Strong lambdas: strong typing over generic types

Unfortunately, I don't know the type of the resulting strong lambdas until after they are mixed-in. This mix-in is defined in the .cpp file and is not available in a header file. In order to get around this limitation I would like to use a concept to limit the type of functor that can be passed into a class or function defined in a separate header file.

If I use a specific phantom tag it seems like this should allow me to write a concept that is limited to strong lambdas that use the same phantom tag type.

I think it should be as simple as adding the line using TagType = Parameter; to the NamedType implementation.

I can then write a concept that is restricted to that TagType

template <typename F>
using StrongLambda = fluent::NamedType<F, struct SpecialLambdaTag>

template <typename T>
concept SpecialLambda = std::is_same_v<typename StrongLambda::TagType, SpecialLambdaTag>;

I have an example on godbolt.org

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