Jonathan Wakely <jwak...@redhat.com> writes:

>> +  for (auto _ : gen("const This& argument", std::allocator_arg , &mr))
>
> I have no idea what the promise_type::operator new overload that takes
> a const This& argument is for, but this invocation of gen uses it, so
> ... yay?

Member coroutines can call that overload:

  struct foo {
    std::generator<int, void, std::allocator<foo>>
    bar(std::allocator_arg_t, std::allocator<foo>) const&
    { co_yield 123; }
  };
  
  void f() {
      foo x;
      x.bar(std::allocator_arg, {});
  }

>> +    VERIFY(mr.number_of_active_allocations() == 1);
>> +
>> +  VERIFY(mr.number_of_active_allocations() == 0);
>> +}
>> diff --git a/libstdc++-v3/testsuite/24_iterators/range_generators/lwg3900.cc
>> b/libstdc++-v3/testsuite/24_iterators/range_generators/lwg3900.cc
>> new file mode 100644
>> index 00000000000..957879e8862
>> --- /dev/null
>> +++ b/libstdc++-v3/testsuite/24_iterators/range_generators/lwg3900.cc
>> @@ -0,0 +1,16 @@
>> +// { dg-do compile { target c++23 } }
>> +
>> +// LWG 3900. allocator_arg_t overloads of generator::promise_type::operator 
>> new
>> +// should not be constrained
>> +
>> +#include <generator>
>> +#include <memory_resource>
>> +
>> +std::pmr::generator<int>
>> +bar(std::allocator_arg_t, std::pmr::memory_resource& mr) // { dg-error 
>> "here" }
>> +{
>> +  co_yield 3;
>> +}
>> +
>> +// { dg-error "static assertion failed" "" { target *-*-* } 0 }
>> +// { dg-error "no matching function .*memory_resource&" "" { target *-*-* } 
>> 0 }
>> --
>> 2.47.1
>>

-- 
Arsen Arsenović

Attachment: signature.asc
Description: PGP signature

Reply via email to