Boost logo

Boost Users :

From: Ruediger Berlich (ruediger.berlich_at_[hidden])
Date: 2007-04-01 14:39:35


Hi again,

apologies for the frequent questions. Here is another problem I've
run into. I think I've found a solution, but would like to cross-check
whether I'm right.

I have a number of templatized base classes, that contain purely virtual
member functions. As per the Boost.Serialization documentation, purely
virtual classes should be labelled as "abstract".

>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:

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.

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>
{ ...};

Would these two options cause any problems ?

Thanks and have a good day,
Ruediger


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