So, I finally had a reason to use polymorphic allocators.
Almost immediately, I discovered what appears to be a fatal design flaw: [mem.res.global]/3-7 doesn't state it outright, but the title of the section and remark about synchronization in [mem.res.global]/6 seem to imply std::pmr::get_default_resource and std::pmr::set_default_resource use a single static (i.e. not thread_local) default memory resource pointer.
Is my reading correct? If so, how is one expected to use polymorphic allocators in multi-threaded programs, considering that std::pmr::get_default_resource would implicitly be used all over the place when copying containers using them? Do I just have to always explicitly pass allocators around?
I was wondering about the same question.
I wrote a simple test where two threads are changing/printing the default resource in order.
It indicates default resource is global, not per thread.
https://coliru.stacked-crooked.com/a/6dbe796556712089
Results: