std::meta::is_defaulted
Defined in header <meta> | ||
|---|---|---|
consteval bool is_defaulted( std::meta::info r ); | (since C++26) |
Returns true if r represents a defaulted function. Otherwise returns false.
Parameters
| r | - | a reflection value |
Return value
true if r represents a defaulted function; otherwise false.
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
{
std::strong_ordering operator<=>(const Derived&) const = default; // implicitly deleted
// operator== is implicitly defaulted due to the defaulted definition of operator<=>
};
static_assert(std::meta::is_defaulted(^^Base::operator==));
static_assert(!std::meta::is_defaulted(^^Base::operator<=>));
static_assert(std::meta::is_defaulted(^^Derived::operator==));
static_assert(std::meta::is_defaulted(^^Derived::operator<=>));
int main() {}
See also
|
(C++26) | checks if reflection represents a function (function) |
|
(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_defaulted