incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <>
Subject Re: test for lib.string.swap
Date Wed, 17 May 2006 16:17:07 GMT
Anton Pevtsov wrote:
> Martin, I updated all tests to use new macro DEFINE_STRING_TEST_DISPATCH
> and allocator.
> The diff file is here:

Thanks for doing that! Please go ahead and apply the changes.

> Martin Sebor wrote:
>> <>PS I noticed that the --no-xxx/--enable-xxx command line options don't
>> <>quite control the overloads they should. I haven't looked into it very
>> closely yet except for adding a missing "-enable-xxx" > string. Are you
>> seeing the same thing on your end?
> Yes. The cause is the missed option "-no-self-ref". The diff file with
> fix attached.

Aha! Let me apply this one.

> I have a question about UserAlloc: how can I instantiate two different
> allocators (i.e. allocators which have different ids)? It looks like
> all allocators in the same scope will have the same id.

Good question! All default-constructed allocators (regardless
of their value_type) share the same SharedAlloc object and thus
have the same id. The same specializations also compare equal.
To construct a UserAlloc object that uses a different SharedAlloc
object you must create it and point the allocator at it. Here's
how to do it:

#include <cassert>
#include <rw_allocator.h>

int main ()
     SharedAlloc a;

     UserAlloc<int> x;
     UserAlloc<int> y;
     UserAlloc<int> z (&a);

     assert (x == y);
     assert (x != z);

     // copies of the same object have the same id regardless
     // of their type
     UserAlloc<double> xx (x);
     UserAlloc<int> xxx (xx);

     assert (x == xxx);

View raw message