[PATCHv8] libstdc++: Add NTTP bind_front, -back, not_fn (P2714) [PR119744]

Nathan Myers ncm@cantrip.org
Thu Sep 11 13:37:09 GMT 2025


On 9/4/25 6:21 AM, Jonathan Wakely wrote:
> On Fri, 01 Aug 2025 at 19:01 -0400, Patrick Palka wrote:
>> Three small review comments below:

>>> diff --git a/libstdc++-v3/testsuite/20_util/headers/functional/ 
>>> synopsis.cc b/libstdc++-v3/testsuite/20_util/headers/functional/ 
>>> synopsis.cc
>>> index e3e92076f5c..5e835d684fd 100644
>>> --- a/libstdc++-v3/testsuite/20_util/headers/functional/synopsis.cc
>>> +++ b/libstdc++-v3/testsuite/20_util/headers/functional/synopsis.cc
>>> @@ -57,6 +57,13 @@ namespace std {
>>>    template <class Predicate>
>>>    _GLIBCXX14_CONSTEXPR
>>>    binary_negate<Predicate> not2(const Predicate&);
>>> +#ifdef __cpp_lib_not_fn
>>> +  template <typename F> _GLIBCXX20_CONSTEXPR auto not_fn(F&&)
>>> +  noexcept(std::is_nothrow_constructible<std::decay_t<F>, F&&>::value);
>>> +#if __cpp_lib_not_fn >= 2020306
>>> +  template <auto f> constexpr auto not_fn() noexcept;
> 
> This doesn't match the declaration in <functional>, which returns
> decltype(auto).
> 
> I think this is just adding a separate overload to
> namespace std, not checking that the one in functional matches the
> expected form.
> 
>>>...
>>> +  template <typename F, typename... Args>
>>> +    _GLIBCXX20_CONSTEXPR auto bind_front(F&&, Args&&...);
> 
> Ditto, the one in <functional> returns the internal type
> _Bind_front_t<_Fn, _Args...> and has a noexcept-specifier.
> 
>>> +#if __cpp_lib_bind_front >= 202306
>>> +  template <auto f, typename... Args> constexpr auto 
>>> bind_front(Args&&...);
> 
> Ditto, the one in <functional> returns decltype(auto) and has a
> noexcept-specifier. And again for the bind_back declarations below.
> 
> This is a recurring problem with our foo/synopsis.cc tests ... adding
> the declaration to the test sometimes reveals mistakes in the
> definition in the lib, but sometimes they just silently add overloads
> and aren't checking anything. I don't have a solution for this.
> 
> Either we should make these declarations match the ones in
> <functional>, or not bother adding them here ... or find some better
> solution for these synopsis tests.

I tried #including the synopsis in a test that calls it,
and the compiler complains about ambiguity if the synopsis
declaration doesn't match the definition.



More information about the Libstdc++ mailing list