Skip to content

Commit

Permalink
Utility: fix the CORRADE_CONSTEXPR14 macro to be empty on MSVC2015.
Browse files Browse the repository at this point in the history
Co-authored-by: Stanislaw Halik <[email protected]>
  • Loading branch information
mosra and sthalik committed Oct 30, 2022
1 parent bee514f commit fbb9305
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions doc/corrade-changelog.dox
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ namespace Corrade {
to load them from OS-specific locations and fail
- @ref TestSuite::Compare::SortedContainer no longer modifies order of
referenced elements when non-owning views are passed to it
- Fixed the @ref CORRADE_CONSTEXPR14 macro be empty on MSVC 2015, which
doesn't support C++14 relaxed constexpr rules yet. See also
[mosra/corrade#152](https://github.com/mosra/corrade/pull/152).

@subsection corrade-changelog-latest-deprecated Deprecated APIs

Expand Down
15 changes: 12 additions & 3 deletions src/Corrade/Utility/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,20 @@ regarding RAII.
@brief C++14 constexpr
@m_since{2020,06}
Expands to @cpp constexpr @ce on C++14 and newer, empty on C++11. Useful for
selectively marking functions that make use of C++14 relaxed constexpr rules.
Expands to @cpp constexpr @ce if C++14 or newer standard is enabled and if the
compiler implements C++14 relaxed constexpr rules (which includes GCC 5+, Clang
3.5+ and MSVC 2017+), empty otherwise. Useful for selectively marking functions
that make use of C++14 constexpr.
@see @ref CORRADE_CXX_STANDARD
*/
#if CORRADE_CXX_STANDARD >= 201402
/* MSVC2015 reports itself as supporting C++14 in _MSVC_LANG (its variant of
__cplusplus, see https://stackoverflow.com/a/74193034) but C++14 constexpr
is only implemented since MSVC2017. The value of __cplusplus is set to
201402 since GCC 5 and Clang 3.5 (https://stackoverflow.com/a/30997455),
while C++14 constexpr is supported since GCC 5 and Clang 3.4. Since those
are both quite old, the check can thus be coarser and just assume that C++14
constexpr is supported only if __cplusplus is 201402. */
#if CORRADE_CXX_STANDARD >= 201402 && !defined(CORRADE_MSVC2015_COMPATIBILITY)
#define CORRADE_CONSTEXPR14 constexpr
#else
#define CORRADE_CONSTEXPR14
Expand Down

2 comments on commit fbb9305

@sthalik
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that's going to break your GCC 4.8 CI instance if this macro ever gets used.

@mosra
Copy link
Owner Author

@mosra mosra commented on fbb9305 Oct 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't. See my last comment to #152 for the full context.

Please sign in to comment.