Boost logo

Boost :

Subject: Re: [boost] [polygon] MSVC8 portability and MSVC8 bugs
From: Christian Henning (chhenning_at_[hidden])
Date: 2009-07-02 14:52:14


The following compiles and uses mpl::and_. Your problem is very
similar to a problem I once had. Steven Watanabe was able to fix by
just leaving out the ::type references. For instance

problem with msvc8:

mpl::and_< my_metafunction<...>::type, my_metafunction2<....>::type >::type

NO problem with msvc8:

mpl::and_< my_metafunction<...>, my_metafunction2<....> >

----------------

#include <boost/mpl/and.hpp>

#include "isotropy.hpp"
#include "rectangle_data.hpp"
#include "point_data.hpp"
#include "point_traits.hpp"
#include "interval_traits.hpp"
#include "rectangle_traits.hpp"
#include "point_concept.hpp"
#include "interval_concept.hpp"
//#include "rectangle_concept.hpp"

using namespace boost::mpl;

namespace boost { namespace polygon {

struct rectangle_concept{};

template <typename T>
struct geometry_concept< rectangle_data< T > >
{
typedef rectangle_concept type;
};

template <typename T>
struct is_mutable_rectangle_concept { typedef gtl_no type; };
template <>
struct is_mutable_rectangle_concept< rectangle_concept > { typedef
gtl_yes type; };

template <typename T>
struct is_rectangle_concept { typedef gtl_no type; };
template <>
struct is_rectangle_concept< rectangle_concept > { typedef gtl_yes type; };

// convolve with point
template< typename rectangle_type
        , typename point_type
>
rectangle_type& convolve( rectangle_type& rectangle
                        , const point_type& convolution_point
                        , typename enable_if< typename mpl::and_<
typename is_mutable_rectangle_concept< typename geometry_concept<
rectangle_type >::type >
                                                                ,
typename is_point_concept < typename geometry_concept<
point_type >::type >
>
                                            , void
>::type *dummy = 0
                        );

template< typename rectangle_type
        , typename interval_type
>
bool
encompass( rectangle_type& rectangle
         , const interval_type& b
         , orientation_2d orient
         , typename enable_if< typename mpl::and_< typename
is_mutable_rectangle_concept< typename geometry_concept<
rectangle_type >::type >
                                               , typename
is_interval_concept < typename geometry_concept< interval_type
>::type >
>
                             , bool
>::type* ptr = 0
         )
{
    return true;
}

// 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 mpl::and_< typename
is_mutable_rectangle_concept<typename
geometry_concept<rectangle_type_1>::type>
                                                 , typename
is_rectangle_concept<typename
geometry_concept<rectangle_type_2>::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 mpl::and_< typename
is_mutable_rectangle_concept< typename
geometry_concept<rectangle_type_1 >::type >
                                                 , typename
is_point_concept < typename geometry_concept<point_type
>::type >
>
                             , void
>::type* dummy = 0
         )
{
    return true;
}

}
}

int main()
{
    using namespace boost;
    using namespace boost::polygon;
    rectangle_data<int> r;
    point_data<int> p;

    encompass(r, p);
    return 0;
}

I hope that fixes your problem and you have a great time fixing all of
your code. ;-) I was there already.

Regards,
Christian


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