Spec-Zone.ru › C++

std::meta::is_user_declared

Defined in header <meta>
consteval bool is_user_declared( std::meta::info r );
(since C++26)

Returns true if r represents a function that is user-declared. Otherwise returns false.

Parameters

r - a reflection value

Return value

true if r represents a user-declared function; otherwise false.

Notes

If r does not represent a function, the result is false. In particular, the result is false if r represents a function template.

Example

#include <meta>

struct Base
{
    bool operator==(const Base&) const = default;
};

struct Derived : public Base
{
    std::strong_ordering operator<=>(const Derived&) const = default;

    // Derived::operator== is declared by the defaulted definition of operator<=>
};

static_assert(std::meta::is_user_declared(^^Base::operator==));
static_assert(!std::meta::is_user_declared(^^Derived::operator==));
static_assert(std::meta::is_user_declared(^^Derived::operator<=>));

int main() {}

See also

is_function
(C++26)
checks if reflection represents a function
(function)
is_user_provided
(C++26)
checks if reflection represents a user-provided function
(function)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/meta/is_user_declared

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API