[cxx] Request for C++ Style Exception: std::function for Swift/C++ Interop

10 views
Skip to first unread message

Asami Doi

unread,
Feb 19, 2026, 12:43:46 PM (yesterday) Feb 19
to c...@chromium.org, Rohit Rao, Sylvain Defresne, Justin Novosad, Mark Cogan
Hi C++ Style Owners,

We are reaching out to request a targeted exception to the style guide's ban on std::function for a specific use case involving Swift/C++ interoperability.

We are currently investigating Swift/C++ interoperability support in Chromium that requires passing callbacks across the C++-to-Swift boundary. Swift's C++ interop layer provides native bridging support for std::function, making it the most viable path for this integration.

We are not proposing to use std::function for general callback handling or to replace Chromium's callback system.
Instead, we plan to use std::function strictly as a wrapper to transport base::RepeatingCallback and base::OnceCallback objects across the C++-to-Swift boundary. By restricting its use to a transport mechanism, we ensure that Chromium's standard callbacks still handle the underlying lifecycle and memory management.
Here is a WIP CL: https://chromium-review.googlesource.com/c/chromium/src/+/7572162

Could you let us know if this approach and exception are acceptable?

Thanks,
Asami

Avi Drissman

unread,
Feb 19, 2026, 2:34:09 PM (yesterday) Feb 19
to Asami Doi, c...@chromium.org, Rohit Rao, Sylvain Defresne, Justin Novosad, Mark Cogan
I would vote for this exception given the narrow scope. (I will admit to bias, being on the Mac team, so I'm hoping to hear more diverse voices as well.)

Avi

--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CALzRO2R8EjZawbwu3QopYNS7pCpuj_mPm3gSgBqT1WQ1%3DMGwXA%40mail.gmail.com.

Joe Mason

unread,
4:35 PM (6 hours ago) 4:35 PM
to Avi Drissman, Asami Doi, c...@chromium.org, Rohit Rao, Sylvain Defresne, Justin Novosad, Mark Cogan
I think https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++-features.md#banned-features-and-third_party-code covers this use case:

Chromium code that calls functions exported from a third-party library may use banned library types that are required by the interface, as long as:

  • The disallowed type is used only at the interface, and converted to and from an equivalent allowed type as soon as practical on the Chromium side.
 

Reply all
Reply to author
Forward
0 new messages