Boost logo

Boost :

Subject: Re: [boost] [polygon] MSVC8 portability and MSVC8 bugs
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2009-07-02 12:53:26


Christian Henning wrote:
> Lucanus, this following compiles just fine with mine MSVC8. I have
> basically moved the enable_if as a function parameter. I hope this
> helps you. I for myself had similar issues when I set up the the new
> gil::io. These compiler errors are very painful to deal with.

It turns out this only works because the two versions of encompass in my example differ in their arguments such that the compiler can disambiguate them without SFINAE.

There are three versions of encompass related to rectangle. The two that work on rectangle,rectangle and rectangle,point respectively still don't compile with your fix:

  // enlarge rectangle to encompass the Rectangle b
  template <typename rectangle_type_1, typename rectangle_type_2>
  bool
  encompass(rectangle_type_1& rectangle, const rectangle_type_2& b,
  typename enable_if< typename gtl_and<
    typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
    typename is_rectangle_concept<typename geometry_concept<rectangle_type_2>::type>::type>::type,
                       void>::type *dummy = 0) { return true; }

  // enlarge rectangle to encompass the point b
  template <typename rectangle_type_1, typename point_type>
  bool
  encompass(rectangle_type_1& rectangle, const point_type& b,
  typename enable_if<
    typename gtl_and<
typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type_1>::type>::type,
typename is_point_concept<typename geometry_concept<point_type>::type>::type>::type,
    void>::type *dummy = 0) { return true; }

The compiler gives a "redefinition of default parameter : parameter 3" for these two overloads, failing to take SFINAE into account. By changing the type from void* to int* the compiler allows them to both instantiate, but then gives a "function call is ambiguous" error because it is using the normal rules for overloading and only by specifying the third parameter would the caller be able to select the correct function.

Luke


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