Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2006-07-25 14:23:49


On Jul 25, 2006, at 1:45 PM, Howard Hinnant wrote:

> namespace Mine
> {
>
> struct Person {};
>
> struct Female : public Person {};
>
> bool isnormal(const Person&);
>
> }
>
> int main()
> {
> using namespace boost; // for boost::bind (just as an example)
> Mine::Female Jane;
> bool b = isnormal(Jane);
> }

If this code doesn't make you nervous (because of the using
directive), the related code below might:

namespace Mine
{

struct sense_of_humor {};

struct Person : private boost::optional<sense_of_humor> {};

struct Female : public Person {};

bool isnormal(const Person&);

bool foo()
{
     Female Jane;
     return isnormal(Jane);
}

} // Mine

int main()
{
     Mine::foo();
}

Again, isnormal will get hijacked by boost::isnormal(T) if it is in
the translation unit (and in namespace boost and not somehow
constrained).

template <class T>
typename enable_if
<
     std::numeric_limits<T>::is_specialized,
     bool
>::type
isnormal(T t) {...}

-Howard


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