Boost logo

Boost :

From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2006-07-18 08:42:36


Philippe Vaucher wrote:

>but what you can do to get the info is :
>
> if(std::distance(tok.begin(), tok.end()) < 3)
> {
> std::cout << "not enough arguments\n";
> exit(1);
> }
>
> arg1=*pos++;
> arg2=*pos++;
> arg3=*pos++;
>
>
Alternatively, you could write a next() function:

template<typename It>
inline typename std::iterator_traits<It>::value_type next(It &first, It
&last)
{
  if(first == last) {
    throw something;
  }
  return *first++;
}

And then just do:

arg1 = next(pos, end);
arg2 = next(pos, end);
arg3 = next(pos, end);

Sebastian Redl


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