Spec-Zone.ru › C++

std::meta::is_user_provided

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

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

Parameters

r - a reflection value

Return value

true if r represents a user-provided 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 <compare>
#include <meta>

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

    std::strong_ordering operator<=>(const Base&) const = delete;
};

bool Base::operator==(const Base&) const = default;

struct Derived : public Base
{
    bool operator==(const Derived&) const { return true; }

    std::strong_ordering operator<=>(const Derived&) const = default;
};

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

int main() {}

See also

is_function
(C++26)
checks if reflection represents a function
(function)
is_deleted
(C++26)
checks if reflection represents a deleted function
(function)
is_defaulted
(C++26)
checks if reflection represents a defaulted function
(function)

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

Spec-Zone.ru

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