ned14 / outcome

Provides very lightweight outcome<T> and result<T> (non-Boost edition)
https://ned14.github.io/outcome
Other
676 stars 62 forks source link

C++20 removed std::is_literal_type #218

Closed StephanTLavavej closed 4 years ago

StephanTLavavej commented 4 years ago

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:

https://github.com/ned14/outcome/blob/627f7842d55ae80239e1a17d521bc14183653d9d/test/tests/constexpr.cpp#L31-L32

In /std:c++17 mode, this triggers a deprecation warning in recent versions of MSVC. In /std:c++latest mode, now that https://github.com/microsoft/STL/pull/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.

After looking at your code briefly, you appear to be testing the constexpr-ness of result and outcome, with several tests for construction, member functions, and destruction. If that's comprehensive, you may simply be able to remove the static_assert(std::is_literal_type lines entirely (or guard them for C++17/20+ mode).

ned14 commented 4 years ago

Thanks for the BR. Nice to know of breakage before end users discover it.

ned14 commented 4 years ago

Fixed, thanks once again for the BR