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

Why strict_not_null<> assignment needs exact same pointer types? #795

Open
shrinktofit opened this issue Jun 26, 2019 · 1 comment
Open
Labels

Comments

@shrinktofit
Copy link

struct A {
};

struct B: A {
};

// true
std::is_assignable_v<gsl::not_null<std::shared_ptr<A>>, gsl::not_null<std::shared_ptr<B>>>;

// false
std::is_assignable_v<gsl::strict_not_null<std::shared_ptr<A>>, gsl::strict_not_null<std::shared_ptr<B>>>;

// true
std::is_constructible_v<gsl::not_null<std::shared_ptr<A>>, gsl::not_null<std::shared_ptr<B>>>;

// true
std::is_constructible_v<gsl::strict_not_null<std::shared_ptr<A>>, gsl::strict_not_null<std::shared_ptr<B>>>;
@ArtemSarmini
Copy link

ArtemSarmini commented Feb 26, 2020

Because is_constructible can call explicit ctors, while is_assignable cannot. I guess it's by design and wontfix, unless std::tuple-like conditional explicit is introduced

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

No branches or pull requests

3 participants