std::numeri..._specialized(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

okay so bestie, welcome to the C++ Standard Libary manual β€” yes, that spelling is exactly what the header says β€” and this page is std::numeri..._specialized(3). We're here for std::numeric_limits::is_specialized, and it's giving tiny-but-iconic boolean main character energy. πŸ’…βœ¨

πŸ’– NAME

  • std::numeric_limits::is_specialized - std::numeric_limits::is_specialized β€” that's literally the name, bestie. No notes, it ate.

✨ Synopsis

The synopsis has two eras, because of course it does:

static const bool is_specialized;      (until C++11)
static constexpr bool is_specialized;  (since C++11)

And the actual tea: the value of std::numeric_limits<T>::is_specialized is true for all T for which there exists a specialization of std::numeric_limits. periodt. 🌈

🌸 Standard specializations

Here's the full roster β€” T on the left, value of std::numeric_limits<T>::is_specialized on the right:

  • /* non-specialized */ β†’ false
  • bool β†’ true
  • char β†’ true
  • signed char β†’ true
  • unsigned char β†’ true
  • wchar_t β†’ true
  • char8_t (since C++20) β†’ true
  • char16_t (since C++11) β†’ true
  • char32_t (since C++11) β†’ true
  • short β†’ true
  • unsigned short β†’ true
  • int β†’ true
  • unsigned int β†’ true
  • long β†’ true
  • unsigned long β†’ true
  • long long (since C++11) β†’ true
  • unsigned long long (since C++11) β†’ true
  • float β†’ true
  • double β†’ true
  • long double β†’ true

🌈 Example

The page says // Run this code, so obviously we run it, bestie:

        #include <iostream>
        #include <limits>
        #include <type_traits>

        int main()
        {
            enum E{};

            std::cout << std::boolalpha
                      << std::numeric_limits<bool>::is_specialized << '\n'
                      << std::numeric_limits<long long>::is_specialized << '\n'
                      << std::numeric_limits<std::true_type>::is_specialized <<
       '\n'
                      << std::numeric_limits<E>::is_specialized << '\n';
        }

Possible output:

        true
        true
        false
        false

πŸ¦‹ See also

Each of these is also [static] β€” (public static member constant), iykyk:

  • is_integer β€” identifies integer types. [static] (public static member constant).
  • is_iec559 β€” identifies the IEC 559/IEEE 754 floating-point types. [static] (public static member constant).
  • is_exact β€” identifies exact types. [static] (public static member constant).
  • is_bounded β€” identifies types that represent a finite set of values. [static] (public static member constant).

mwah πŸ’‹ β€” source/version: http://cppreference.com, dated 2024.06.10, page std::numeri..._specialized(3). slay and goodbye πŸŽ€

πŸ“¦ where this page comes from