Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-01-22 18:45:08


Rob Stewart <stewart_at_[hidden]> writes:

> From: David Abrahams <dave_at_[hidden]>
>> "Giovanni Bajo" <giovannibajo_at_[hidden]> writes:
>> > Hartmut Kaiser wrote:
>> >
>> >> I usually use another compiler to spot the errors, returning
>> >> afterwards to my production compiler - the VC7.1).
>> >
>> > Same here. Comeau has the best error messages by far, imo.
>>
>> Comeau is nasty! Try this on it, for example:
>>
>> # include <map>
>> # include <vector>
>> # include <algorithm>
>> int main()
>> {
>> std::map<int,int> a;
>> std::vector<int> v(20);
>> std::copy(a.begin(), a.end(), v.begin());
>> return 0;
>> }
>
> Not bad with STLFilt:
>
> stl_algobase.h(144): error: no suitable conversion function from
> "pair<int,int>" to "vector<int>::value_type" exists
> *__result = *__first;

You miss my point. vector<int>::value_type is impenetrable, except
that you happen to know something about the definition of
std::vector. In a complicated template program, that could be a
mystery type.

Try this one on for size, and compare with GCC:

  # include <boost/mpl/transform.hpp>
  # include <boost/mpl/vector/vector10.hpp>

  namespace mpl = boost::mpl;
  using namespace mpl::placeholders;
  template <class T>
  struct returning_ptr
  {
      typedef T* (&type)();
  };

  typedef mpl::transform<
        mpl::vector5<int&,char,long[5],bool,double>
      , returning_ptr<_1>
>::type func_pointers;

There's nothing STLFilt can do to help you with that result.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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