|
Boost : |
From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-03-01 06:34:54
"Dirk Gerrits" <dirk_at_[hidden]> wrote in message
news:3E605C5E.905_at_gerrits.homeip.net...
[snip]
> At what cost? The strings you generate are indeed very readable, but
> specializing spelling for every type that might be a template parameter
> someday seems like too much of a burden to me.
>
> Others might disagree though...
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.
regards
Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk