[Bug libstdc++/122032] New: The size of bind_front/bind_back<fn>(...) is not optimized
hewillk at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Sep 22 15:13:25 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122032
Bug ID: 122032
Summary: The size of bind_front/bind_back<fn>(...) is not
optimized
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
They return lambdas, which miss out on size optimizations compared to using
specialized structs like _Bind_front_t, such as EBO.
#include <functional>
struct Empty1 { };
struct Empty2 { };
struct Empty3 { };
struct Empty4 { };
struct Empty5 { };
struct Empty6 { };
struct Empty7 { };
struct Empty8 { };
Empty1 e1;
Empty2 e2;
Empty3 e3;
Empty4 e4;
Empty5 e5;
Empty6 e6;
Empty7 e7;
Empty8 e8;
struct Fun { void operator()(auto...) { } };
auto b1 = std::bind_front<Fun{}>(e1, e2, e3, e4, e5, e6, e7, e8);
auto b2 = std::bind_front(Fun{}, e1, e2, e3, e4, e5, e6, e7, e8);
static_assert(sizeof(b1) == 8);
static_assert(sizeof(b2) == 1);
More information about the Gcc-bugs
mailing list