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

C++20 removed std::is_literal_type #95

Open
StephanTLavavej opened this issue Feb 3, 2020 · 0 comments
Open

C++20 removed std::is_literal_type #95

StephanTLavavej opened this issue Feb 3, 2020 · 0 comments

Comments

@StephanTLavavej
Copy link

std::is_literal_type was deprecated in C++17 and removed in C++20. Section [diff.cpp17.depr]/7 of the C++20 Working Draft explains:

The traits had unreliable or awkward interfaces. The is_­literal_­type trait provided no way to detect which subset of constructors and member functions of a type were declared constexpr.

This trait is being directly used here:

: public sprout::detail::type_traits_wrapper<std::is_literal_type<T> >

In /std:c++17 mode, this triggers a deprecation warning in recent versions of MSVC. In /std:c++latest mode, now that microsoft/STL#380 has been merged, this will trigger an error in VS 2019 16.6 Preview 2.

MSVC provides "escape hatch" macros that can be defined project-wide to suppress the deprecation warning and restore the removed type trait. (Specifically, compiling with /D_SILENCE_CXX17_IS_LITERAL_TYPE_DEPRECATION_WARNING and /D_HAS_DEPRECATED_IS_LITERAL_TYPE=1.) However, it's best to avoid using this deprecated/removed machinery entirely.

I see at least three uses of sprout::is_literal_type throughout your codebase, but I'm uncertain as to how it's being used. I looked at prev, where it appears to be dispatching to logarithmic-depth recursion, possibly as a workaround when C++14 extended constexpr is unavailable. If all uses of is_literal_type are for dealing with the limitations of C++11 classic constexpr, you may want to detect whether C++14 extended constexpr is available, and if so, avoid is_literal_type entirely (which should solve the deprecation/removal issue with the latest versions of MSVC).

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