diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2018-12-10 17:19:52 -0500 |
---|---|---|
committer | Henrik Edin <henrik.edin@mongodb.com> | 2018-12-11 13:04:38 -0500 |
commit | bb5334681508ceafe4dc174f76e6573e7cae1366 (patch) | |
tree | d2c0045ba13e11ae6f0113d94627ff8db0f255c1 /src/mongo/stdx | |
parent | afe80e6c70b5658f717a268f698c305c098fbc92 (diff) | |
download | mongo-bb5334681508ceafe4dc174f76e6573e7cae1366.tar.gz |
SERVER-38520 Fix std::variant feature detection
Diffstat (limited to 'src/mongo/stdx')
-rw-r--r-- | src/mongo/stdx/variant.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/mongo/stdx/variant.h b/src/mongo/stdx/variant.h index 374432fac5e..4de52b0fe2d 100644 --- a/src/mongo/stdx/variant.h +++ b/src/mongo/stdx/variant.h @@ -30,15 +30,21 @@ #pragma once -#ifndef __cpp_lib_variant -#include "third_party/variant-1.3.0/include/mpark/variant.hpp" -#else +// Feature detection is messy in C++17 (to be improved in C++20 with the <version> header). +// __cpp_lib_variant is available to check after <variant> is included. Include it if it's available +// (but only if C++17 as MSVS makes it available but emits a message if used). If the variant lib is +// not high enough version, fall back to mpark. +#if __cplusplus >= 201703L && defined(__has_include) && __has_include(<variant>) #include <variant> #endif +#if !defined(__cpp_lib_variant) || __cpp_lib_variant < 201603 +#include "third_party/variant-1.3.0/include/mpark/variant.hpp" +#endif + namespace mongo { namespace stdx { -#if __cplusplus < 201703L || !defined(__cpp_lib_variant) +#if !defined(__cpp_lib_variant) || __cpp_lib_variant < 201603 using ::mpark::variant; using ::mpark::visit; using ::mpark::holds_alternative; |