Boost logo

Boost :

From: Tomasz Kowalczyk (tomek_at_[hidden])
Date: 2000-05-28 08:14:47


David Abrahams wrote:
> > I would like to ask to add a nil structure to utility.hpp. It is useful
> > for specifying empty arguments in template specializations. For example:
> >
> > template <class T1 = nil>
> > struct F {
> > void f(T1);
> > };
> >
> > template <>
> > struct F<> {
> > void f();
> > };
>
> I don't see nil being used in the specialization... perhaps the use of a
> default template parameter is just obscuring the issue?

The above code is my (bad?) habit :) and is equivalent to:

template <class T1 = nil>
struct F {
        void f(T1);
};

template <>
struct F<nil> {
        void f();
};

> > Lambda library and Peter Dimov's expression library use this technique
> > extensively, and I have found myself using it a lot too. Why not to
> > place a structure like this in a common, well known place, so that
> > people using or contributing to boost do not have to invent the same
> > thing with a different name again and again ?
> >
>
> Only one reason I can think of: there's a "universal null-pointer class"
> (which is arguably more generally useful), which we probably ought to add to
> the library, and the names might be easily confused. It's not a big deal,
> but something to consider, maybe. What about "empty"?
>
> -Dave

May be "empty". It's longer to write but I like it.
What about "none" ?

Tomasz


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