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

CTAD on MSVC fails #29

Open
EmilyMansfield opened this issue Jun 10, 2019 · 2 comments
Open

CTAD on MSVC fails #29

EmilyMansfield opened this issue Jun 10, 2019 · 2 comments

Comments

@EmilyMansfield
Copy link

Hi, first of all thanks for this library!

On MSVC 19.21 with C++17, CTAD fails with tl::optional whereas it works with std::optional:

tl::optional o = 3; // Cannot deduce T
std::optional o = 3; // Deduces T to be int

I think this is just a case of missing std::optional's deduction guide, since adding that in fixes it, but strangely Clang and GCC don't seem to need the guide and deduce T to be int anyway. I don't know enough about CTAD to know exactly what's going on here, so sorry if this isn't actually a bug in tl::optional and is instead a compiler bug.

@TartanLlama
Copy link
Owner

Thanks for the report! Ah, it's because MSVC doesn't set __cplusplus properly unless you pass /Zc:__cplusplus, and the deduction guide is behind an ifdef. Will see if there's a more foolproof way of detecting C++17 mode for MSVC without that switch.

@EmilyMansfield
Copy link
Author

Ah gotcha, that's good to know in general! I'll set that switch for now, thanks 👍

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

2 participants