| 1 |
// { dg-do compile { target c++20 } } |
| 2 |
|
| 3 |
#include <functional> |
| 4 |
|
| 5 |
struct Foo |
| 6 |
{ |
| 7 |
void func() {} |
| 8 |
}; |
| 9 |
|
| 10 |
void bar() { } |
| 11 |
|
| 12 |
// PR libstdc++/107784 - QOI: sizeof( bind_front( Member-Function ) ) too big |
| 13 |
static_assert( sizeof(std::bind_front(&Foo::func)) == sizeof(&Foo::func) ); |
| 14 |
static_assert( sizeof(std::bind_front(&bar)) == sizeof(&bar) ); |
| 15 |
|
| 16 |
// PR libstdc++/108290 - QoI: bind_front captureless lambda is too big |
| 17 |
auto empty_lambda = [](auto, auto) { return 0; }; |
| 18 |
|
| 19 |
struct { |
| 20 |
void operator()(int, int, int) { } |
| 21 |
template<typename T> void operator()(T, T) { } |
| 22 |
} empty_class; |
| 23 |
|
| 24 |
static_assert(sizeof(std::bind_front(empty_lambda)) == 1); |
| 25 |
static_assert(sizeof(std::bind_front(empty_lambda, 1)) == sizeof(int)); |
| 26 |
static_assert(sizeof(std::bind_front(empty_lambda, empty_lambda)) == 2); |
| 27 |
static_assert(sizeof(std::bind_front(empty_lambda, empty_class)) == 1); |
| 28 |
static_assert(sizeof(std::bind_front(empty_lambda, 1, 2)) == 2 * sizeof(int)); |
| 29 |
static_assert(sizeof(std::bind_front(empty_lambda, '1', empty_lambda)) == 2); |
| 30 |
static_assert(sizeof(std::bind_front(empty_lambda, '1', empty_class)) == 1); |
| 31 |
|
| 32 |
static_assert(sizeof(std::bind_front(empty_class)) == 1); |
| 33 |
static_assert(sizeof(std::bind_front(empty_class, 1)) == sizeof(int)); |
| 34 |
static_assert(sizeof(std::bind_front(empty_class, empty_lambda)) == 1); |
| 35 |
static_assert(sizeof(std::bind_front(empty_class, empty_class)) == 2); |
| 36 |
static_assert(sizeof(std::bind_front(empty_class, 1, 2)) == 2 * sizeof(int)); |
| 37 |
static_assert(sizeof(std::bind_front(empty_class, '1', empty_lambda)) == 1); |
| 38 |
static_assert(sizeof(std::bind_front(empty_class, '1', empty_class)) == 2); |
| 39 |
|
| 40 |
struct derived1 : decltype(std::bind_front(empty_class)) |
| 41 |
{ |
| 42 |
int i; |
| 43 |
}; |
| 44 |
static_assert(sizeof(derived1) == sizeof(int)); |
| 45 |
|
| 46 |
struct derived2 : decltype(std::bind_front(empty_class, empty_lambda)) |
| 47 |
{ |
| 48 |
int i; |
| 49 |
}; |
| 50 |
static_assert(sizeof(derived2) == sizeof(int)); |