Boost logo

Boost :

From: Corrado Zoccolo (czoccolo_at_[hidden])
Date: 2007-11-20 15:00:15


Hi Steven,

On Nov 19, 2007 7:37 PM, Steven Watanabe <steven_at_[hidden]>
wrote:

> AMDG
>
> Both "new T" and has_new<T> look in base
> classes of T. SFINAE seems to work on both msvc 8.0 and gcc 3.4.4
>
> I think that what I would do is create a generic allocator
> that looks up the correct operator new/delete
> <snipped allocator code>

I tested with this code:

typedef void * (*new_signature_t)(size_t);

template<typename T, T U>
struct has_ {
  typedef T type;
};

template<typename T>
typename has_<new_signature_t, &T::operator new>::type get_new(T*) { return
T::operator new; }

new_signature_t get_new(...) { return ::operator new; }

and it actually works with recent compilers like g++ 4.1.2, but it fails on
g++ 3.3.5, on a simple usage like:
struct A {};
int main() {
  A* a_= ::new( get_new((A*)0)(sizeof(A)) ) A();
  return 0;
}

with the following error:
test_alloc.cc:88: error: `operator new' is not a member of type `A'

It seems that on this compiler, the substitution failure of a pointer to
(static) member function is actually treated as error.

Do you know some technique/workaround to make this work also on g++ 3.3? It
is the compiler I'm using at work, so I'd like to support it even if it is
outdated.
Is there a BOOST defect macro for this behavior, to enable workarounds when
the compiler cannot handle it?

Thanks,
Corrado

-- 
__________________________________________________________________________
dott. Corrado Zoccolo                          mailto:zoccolo_at_[hidden]
PhD - Department of Computer Science - University of Pisa, Italy
--------------------------------------------------------------------------
The self-confidence of a warrior is not the self-confidence of the average
man. The average man seeks certainty in the eyes of the onlooker and calls
that self-confidence. The warrior seeks impeccability in his own eyes and
calls that humbleness.
                              Tales of Power - C. Castaneda

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk