Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2000-02-01 02:17:59


Dave Abrahams <abrahams_at_[hidden]> wrote:

> > 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 ) ); // (*)
> > | //...
> > | }
> > |};
>
> Yeah, but boost::geometry2d::make_point was supposed to make a
> boost::geometry2d::point (remember its a substitute for a constructor), so
> it doesn't do much good ;)
>
> I assumed the template parameter(s) would say what types the x and y
> coordinates were.
>

Opps.. I've misunderstood you - I thought you suggest
'boost::geometry2d::make_point' to be a substitute for both the constructor
and for the conversion operator - in such the case it can be used like this:

| typedef boost::geometry2d::point<long> point;
| point p1;
| POINT p2( make_point<POINT>( p1 ) ); // as a conversion operator
| point p3( make_point<point>( p2 ) ); // as a constructor

Does it make sense for you, Dave?

> > 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...
>
> Hmm. Does it work when you qualify NS::f?
>

Yes, it works...

> > ....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...
>
> You've lost me here...
>

Nevermind, Dave ;) - yet another misunderstanding on my
part...

- Alexy


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