Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2007-04-01 16:28:26


Ruediger Berlich wrote:

>> From the documentation and the header file "is_abstract.hpp" it
>> appears as
> if using the macro BOOST_IS_ABSTRACT would not work (indeed it
> produces lots of error messages) for templatized classes, but that I
> should instead add the following to the header:

In general, preprocessor macros don't work for templated classes. This
is described in the manual.
>
> namespace boost {
> namespace serialization {
> template<class T>
> struct is_abstract<myClass<T> > {
> typedef mpl::bool_<true> type;
> BOOST_STATIC_CONSTANT(bool, value = true);
> };
> }}
>
> Indeed this seems to work.

so one has to avoid the macro and drop down to the underlying source
code. - just as you have done.

>
> It appears to me as if another solution might be to use the original
> macro in those files where the templatized classes are first
> instantiated (i.e. "filled" with a type). Please note, though, that
> they are base-classes for some other non-abstract classes, so that
> I'm not sure this would work. Anyway, the idea would be something
> along the lines of
>
> // [...]
> // myClass<myType> is no longer a template
> BOOST_IS_ABSTRACT(myClass<myType>)
>
> class derived
> :public myClass<myType>
> { ...};

I believe that above would also work. Of course you have to do it
for every "myType" so some of the convenience of the macro is lost
but currently I see no other way.

Robert Ramey


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net