CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: C++ new specification syntax problem

  1. #1
    Join Date
    Dec 2010

    C++ new specification syntax problem

    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.

    #define ABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \
      ABSL_INTERNAL_EXTERN_DECL(type, name)                  \
      inline constexpr ::absl::internal::identity_t<type> name = init
    // 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

    // Problem A
    // error C2131: expression did not evaluate to a constant
    ABSL_INTERNAL_INLINE_CONSTEXPR(in_place_t, in_place, {});

    // 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,

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012

    Re: C++ new specification syntax problem

    Try removing constexpr from the #defines.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.7.4)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)