std::experi...ect::Object(3)
π NAME π
okay so bestie, welcome to the std::experi...ect::Object(3) page from the C++ Standard Libary manual. (Yes, βLibaryβ β we keep the typo, sheβs iconic π
.) The NAME line is literally std::experimental::reflect::Object - std::experimental::reflect::Object, and the whole page is about std::experimental::reflect::Object in the reflection TS. No cap, itβs giving βconcept girlβ energy. β¨
β¨ Synopsis β¨
hereβs the exact synopsis, bestie β donβt let the spacing gaslight you:
Defined in header <experimental/reflect>
template< class T > (reflection TS)
concept Object = /* see below */;
Quick vibe check: the Object concept is satisfied if and only if T is a meta-object type. periodt. π
πΈ Example πΈ
this example is doing the most in the cutest way: it defines meta_t, operator==, operator!=, and meta, then runs a static_assert. Copy it exactly, including the slightly feral line break in the static_assert β itβs part of the example π:
// Run this code
#include <experimental/reflect>
namespace reflect = std::experimental::reflect;
template<reflect::Object M>
struct meta_t {
template<reflect::Object M1>
friend constexpr bool operator==(meta_t, meta_t<M1>) noexcept
{
return reflect::reflects_same_v<M, M1>;
}
template<reflect::Object M1>
friend constexpr bool operator!=(meta_t, meta_t<M1>) noexcept
{
return !reflect::reflects_same_v<M, M1>;
}
};
template<reflect::Object M>
constexpr meta_t<M> meta{};
int main()
{
static_assert(meta<reflexpr(int)> == meta<reflexpr(signed int)>,
"");
// meta<int>; // error: int is not a meta-object type
}
and thatβs the whole page, bestie β short, sweet, and fully meta. π¦
cute sign-off time π: source/version is http://cppreference.com, date is 2024.06.10, and the page is std::experi...ect::Object(3). mwah π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms