Boost logo

Boost :

From: Robert Allan Schwartz (notbob_at_[hidden])
Date: 2003-03-01 10:10:53


> I think that is a problem too. Maybe a macro could make things easier:
>
> #define DECLARE_SPELLABLE( a_type ) \
> template<> class spelling<a_type> { public: static const std::string
> result; }; \
> const std::string spelling<my_enum>::result = #a_type
>
> but this should be preferrable be put in headers, so why not make the
static
> data into a function instead?
> Like this:
>
> template< typename T >
> class spelling
> {
> public:
> const string& result() const
> {
> static const string res = ..;
> return res;
> }
> };
>
> And the macro could be changed accordingly.

Looks good to me.

Robert


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