rary
    #    include <boost/optional.hpp>
    #  else                                        // Not found at all
    #     error "Missing <optional>"
    #  endif
    #endif
     
    #ifdef __has_cpp_attribute                      // Check if __has_cpp_attribute is present
    #  if __has_cpp_attribute(deprecated)           // Check for an attribute
    #    define DEPRECATED(msg) [[deprecated(msg)]]
    #  endif
    #endif
    #ifndef DEPRECATED
    #    define DEPRECATED(msg)
    #endif
     
    DEPRECATED("foo() has been deprecated") void foo();
     
    #if __cpp_constexpr >= 201304                // Check for a specific version of a feature
    #  define CONSTEXPR constexpr
    #else
    #  define CONSTEXPR inline
    #endif
     
    CONSTEXPR int bar(unsigned i)
    {
    #if __cpp_binary_literals                    // Check for the presence of a feature
        unsigned mask1 = 0b11000000;
        unsigned mask2 = 0b00000111;
    #else
        unsigned mask1 = 0xC0;
        unsigned mask2 = 0x07;
    #endif
        if (i & mask1)
            return 1;
        if (i & mask2)
            return 2;
        return 0;
    }
     
    int main() {}

####  [ [ edit ](/mwiki/index.php?title=cpp/feature_test&action=edit&section=6
"Edit section: Compiler Features Dump") ]  Compiler Features Dump

[ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/compiler_support/dump&action=edit)

The following (C++11 compatible) program dumps C++ compiler features and
attributes. Note that the use of  __has_cpp_attribute  (  )  is not [
conformant ](/w/cpp/feature_test#Attributes "cpp/feature test") and depends on
the gcc/clang implementation.

Run this code

    
    
    static constexpr struct change_these_options_to_select_what_will_be_printed
    {
        constexpr static int longest_macro_name { 45 };
        constexpr static bool titles               = 1;
        constexpr static bool counters             = 1;
        constexpr static bool attributes           = 1;
        constexpr static bool standard_values      = 1;
        constexpr static bool compiler_specific    = 1;
        constexpr static bool core_features        = 1;
        constexpr static bool lib_features         = 1;
        constexpr static bool supported_features   = 1;
        constexpr static bool unsupported_features = 1;
        constexpr static bool sort_by_date         = 0;
        constexpr static bool separate_year_month  = 1;
        constexpr static bool separated_revisions  = 1;
        constexpr static bool latest_revisions     = 1;
        constexpr static bool cxx98                = 0;
        constexpr static bool cxx11                = 1;
        constexpr static bool cxx14                = 1;
        constexpr static bool cxx17                = 1;
        constexpr static bool cxx20                = 1;
        constexpr static bool cxx23                = 1;
        constexpr static bool cxx26                = 1;
        constexpr static bool cxx29                = 0;
    } print;
     
    #if __cplusplus < 201100
    #  error "C++11 or better is required"
    #endif
     
    #include <algorithm>
    #include <cstdio>
    #include <cstring>
    #include <utility>
    #include <vector>
     
    #ifdef __has_include
    # if __has_include(<version>)
    #   include <version>
    # endif
    #endif
     
    // Expect a string that starts with 6-decimal-digits or with '_' (if unsupported)
    #define COMPILER_VALUE_INT(n) #n [0] == '_' ? 0 : \
        (#n[5] - '0') + (#n[4] - '0') * 10 + (#n[3] - '0') * 100 + \
        (#n[2] - '0') * 1000 + (#n[1] - '0') * 10000 + (#n[0] - '0') * 100000
    #define COMPILER_FEATURE_ENTRY(expect, name) { #name, COMPILER_VALUE_INT(name), expect },
     
    #if defined(__has_cpp_attribute) && defined(__GNUG__)
    # define COMPILER_ATTRIBUTE(expect, name) { #name, __has_cpp_attribute(name), expect },
    #else
    # define COMPILER_ATTRIBUTE(expect, name) { #name, COMPILER_VALUE_INT(name), e