Hello guys,
I have some trouble understanding the following syntax.
This is supposed to be compiled under VS2019. Now, I want to compile it under 2015. How to make the changes to make them compatible?
C++ has been evolving to a more and more cryptic standard. Really.
Code:
#define ABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \
ABSL_INTERNAL_EXTERN_DECL(type, name) \
inline constexpr ::absl::internal::identity_t<type> name = init
#else
// See above comment at top of file for details.
//
// Note:
// identity_t is used here so that the const and name are in the
// appropriate place for pointer types, reference types, function pointer
// types, etc..
#define ABSL_INTERNAL_INLINE_CONSTEXPR(var_type, name, init) \
template <class /*AbslInternalDummy*/ = void> \
struct AbslInternalInlineVariableHolder##name { \
static constexpr ::absl::internal::identity_t<var_type> kInstance = init; \
}; \
\
template <class AbslInternalDummy> \
constexpr ::absl::internal::identity_t<var_type> \
AbslInternalInlineVariableHolder##name<AbslInternalDummy>::kInstance; \
\
static constexpr const ::absl::internal::identity_t<var_type>& \
name = /* NOLINT */ \
AbslInternalInlineVariableHolder##name<>::kInstance; \
static_assert(sizeof(void (*)(decltype(name))) != 0, \
"Silence unused variable warnings.")
#endif // __cpp_inline_variables
Code:
// Problem A
// error C2131: expression did not evaluate to a constant
ABSL_INTERNAL_INLINE_CONSTEXPR(in_place_t, in_place, {});
Code:
// Problem B
// error C4579: 'absl::AbslInternalInlineVariableHoldernullopt<void>::kInstance':
// in-class initialization for type 'const absl::nullopt_t' is not yet implemented; static member will remain uninitialized at runtime but use in constant-expressions is supported
ABSL_INTERNAL_INLINE_CONSTEXPR(nullopt_t, nullopt,
nullopt_t(optional_internal::init_t()));