Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2000-01-31 04:04:38


Dave Abrahams <abrahams_at_[hidden]> wrote:

> On quick inspection, it looks like you're creating namespace
> boost::geometry2d::std when you specialize less.
>

Opps! You are right, of course.. I've fixed it.

> These lightweight classes are cheap to return by value, so I think free
> functions boost::make_rectangle<T>(...) and boost::make_point<T>(...)
> would be a better choice. We can allow users (or platforms) to overload
> these in namespace boost.
>

Probably they'll be indeed a better choice at least because the most of
today's compilers deal with ordinary template functions much better than
with member-template conversion operators...

Two questions, Dave:

1) Why do you prefer to put these functions into 'boost' namespace, but not
into 'boost::geometry2d'? In the last case we may exploit Koenig lookup,
and write something like

| class canvas {
| public:
| typedef boost::geometry2d::point<long> point;
| void draw_something( const point& p )

| POINT tmp( make_point<POINT>( p ) ); // (*)
| //...
| }
|};

instead 'POINT tmp( boost::make_point<point>( p ) );'...
Which of course may be a disadvantage from your point of view ;)
BTW, Metrowerks 5.0 happily compiles code like

| namespace NS {
| template<class U> class T {};
| template<class U> void f( T<U> );
| }
|
| NS::T<long> param;
| void foo() { f( param ); }

but refuses this one

| namespace NS {
| template<class U> class T {};
| template<class U1, class U2> U1 f( T<U2> );
| }
|
| NS::T<long> param;
| void foo() { f<bool>( param ); }

It's quite puzzling for me - I suppose this to be a bug...

...but the second question
2) Why
'template<class T> T boost::make_rectangle<T>(...) {}'
but not just
'template<class T> T boost::make_rectangle<T>() {}'?

I suppose there is a reason, so I'm curious...

-Alexy


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