Commit fc88fcbf authored by Eric Niebler's avatar Eric Niebler Committed by Facebook Github Bot

add Folly portability macros for C++17 inline variables

Summary: Add a portability macro for testing whether the compiler supports C++17's inline variables.

Reviewed By: yfeldblum

Differential Revision: D17957184

fbshipit-source-id: bff7d2bc15867e32f787860b4f8e5a0176ac1017
parent bfdc0a57
......@@ -507,6 +507,14 @@ constexpr auto kCpplibVer = 0;
#define FOLLY_HAVE_NOEXCEPT_FUNCTION_TYPE 1
#endif
#if __cpp_inline_variables >= 201606L
#define FOLLY_HAS_INLINE_VARIABLES 1
#define FOLLY_INLINE_VARIABLE inline
#else
#define FOLLY_HAS_INLINE_VARIABLES 0
#define FOLLY_INLINE_VARIABLE
#endif
// feature test __cpp_lib_string_view is defined in <string>, which is
// too heavy to include here. MSVC __has_include support arrived later
// than string_view, so we need an alternate case for it.
......
......@@ -16,6 +16,7 @@
#pragma once
#include <folly/Portability.h>
#include <folly/lang/StaticConst.h>
// FOLLY_DEFINE_CPO
......@@ -31,7 +32,7 @@
// ensure that there is only a single instance of the CPO created and then a
// named reference in an anonymous namespace is required to avoid duplicate
// symbol definitions.
#if __cpp_inline_variables >= 201606L
#if FOLLY_HAS_INLINE_VARIABLES
#define FOLLY_DEFINE_CPO(Type, Name) \
namespace folly_cpo__ { \
inline constexpr Type Name{}; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment