Boost logo

Boost :

From: Dirk Gerrits (dirk_at_[hidden])
Date: 2003-03-02 14:53:06


Dirk Gerrits wrote:
> Thorsten Ottosen wrote:
>
>> I see your point. Does anyone have a nice idea of how to detect when the
>> template argument is an iterator? It's easy with pairs and arrays and the
>> default case is containers.
>
>
> Perhaps you can use Boost's concept check to see if the template
> argument models the Input Iterator concept? That's the first thing that
> came to mind, I haven't tried it out or anything.

On second thought, that won't work. Concept check causes a compilation
error when the argument does not conform to the concept.

Perhaps you can do it the other way around? Check for a T::begin member
function to see if the type is a container, and assume the type is an
iterator in the default case? I'm not sure what that check would look
like though.

Dirk Gerrits


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