From ded7cf916f0234e0d6b33814303f6bacf7b5a18f Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Thu, 17 Nov 2016 20:08:43 +0000 Subject: [PATCH] Workaround compilers w/o C++1z inline variables llvm-svn: 287255 --- libcxx/include/__config | 5 +++++ libcxx/include/utility | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/libcxx/include/__config b/libcxx/include/__config index e9d3e5f..a8603be 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -796,6 +796,11 @@ template struct __static_assert_check {}; #define _LIBCPP_CONSTEXPR_AFTER_CXX14 #endif +// FIXME: Remove all usages of this macro once compilers catch up. +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606L) +# define _LIBCPP_HAS_NO_INLINE_VARIABLES +#endif + #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES # define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x) #else diff --git a/libcxx/include/utility b/libcxx/include/utility index 52c062d..3642214 100644 --- a/libcxx/include/utility +++ b/libcxx/include/utility @@ -897,21 +897,30 @@ _T1 exchange(_T1& __obj, _T2 && __new_value) struct _LIBCPP_TYPE_VIS in_place_t { explicit in_place_t() = default; }; -inline constexpr in_place_t in_place{}; +#ifndef _LIBCPP_HAS_NO_INLINE_VARIABLES +inline +#endif +constexpr in_place_t in_place{}; template struct _LIBCPP_TYPE_VIS in_place_type_t { explicit in_place_type_t() = default; }; template -inline constexpr in_place_type_t<_Tp> in_place_type{}; +#ifndef _LIBCPP_HAS_NO_INLINE_VARIABLES +inline +#endif +constexpr in_place_type_t<_Tp> in_place_type{}; template struct _LIBCPP_TYPE_VIS in_place_index_t { explicit in_place_index_t() = default; }; template -inline constexpr in_place_index_t<_Idx> in_place_index{}; +#ifndef _LIBCPP_HAS_NO_INLINE_VARIABLES +inline +#endif +constexpr in_place_index_t<_Idx> in_place_index{}; template struct __is_inplace_type_imp : false_type {}; template struct __is_inplace_type_imp> : true_type {}; -- 2.7.4