Boost logo

Boost :

Subject: Re: [boost] [geometry] view_as concept casting
From: Barend Gehrels (barend_at_[hidden])
Date: 2009-01-08 16:21:44

Hi David,

Thanks for your suggestions.

David Abrahams wrote:
>> template <typename P> double area(const P& polyon,
>> typename boost::enable_if_c<geometry_type<P>::type
>> == TYPE_POLYGON>::type* = 0)
>> This works perfectly and distinguishes all geometry types at compile
>> time, as long as the library or the developer provides the meta function
>> geometry_type<T>::type which is currently implemented as an enumeration
>> of TYPE_POINT, etc.
> Seems like you might be better off using tag dispatching... or something
> like
You are right. The system using enable_if_c works and is recommended by
the boost doc of enable_if :-). (quote: The enable_if family of
templates is a set of tools to allow a function template or a class
template specialization to include or exclude itself from a set of
matching functions or specializations based on properties of its
template arguments)

But tag dispatching works perfectly as well and I see that there are
more advantages.

>> We therefore use
>> BOOST_CONCEPT_REQUIRES instead of _ASSERT in such cases.
> I think you mean the opposite, right?
Sure, the opposite, sorry for the mistake.

Regards, Barend

Boost list run by bdawes at, gregod at, cpdaniel at, john at