Boost logo

Boost Users :

From: Mark Storer (mstorer_at_[hidden])
Date: 2002-09-24 17:33:50


Couldn't you do something along the lines of:

template < typename PointerT, typeName RefereceT = &(*PointerT) >

Only I think that's an address rather than a reference...

How about:

template < typename T >
void f( T *ptr )
{
      T &ref = *ptr;
      // ... do something with ref ...
}

And what do you have against "->"? I don't think a reference's "." is any
faster than a pointer's "->", so that shouldn't be a concern... just trying
to save some knuckle grease? I don't get it. (I'm getting a lot of
practice with that phrase since I started digging into STL & Boost)

--Mark Storer
  Software Engineer
  Cardiff Software

#include <disclaimer>
typedef std::disclaimer<Cardiff> Discard;

-----Original Message-----
From: Bohdan [mailto:yg-boost-users_at_[hidden]]
Sent: Monday, September 23, 2002 7:38 AM
To: boost-users_at_[hidden]
Subject: [Boost-Users] pointer traints ?

I have following code:

template < typename PointerT >
void f( PointerT ptr )
{
      ReferenceT ref = *ptr;
      // ... do something with ref ...
}

The problem is that ReferenceT is unknown inside f( ... ).
If i had similar code for InteratorT instead of PointerT i was using
iterator_traits.
AFAIK there is no pointer traits for a raw and smart pointers and i can not
use type_traits
for smart pointers.
So, the question is: "Is there some simple solution for this problem or this
is just
lack of pointer_traits in boost (std?) ?"

regards,
bohdan

Info: <http://www.boost.org>
Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net