Boost logo

Geometry :

Subject: [ggl] Naming template parameters
From: Mateusz Loskot (mateusz)
Date: 2009-05-03 10:59:26


Mateusz Loskot wrote:
> Barend Gehrels wrote:
>> Hi,
>>
>>> What do you think about stealing template parameters naming from
>>> Spirit so they are yet easier to recognize.
>>>
>>> We've agreed to use CamelCase, but Spirit proposes a slight
>>> modification: CamelCaseT with T postfix.
>> I thought about it. It sounds not too attractive to me. The changes
>> we made until sofar were to comply to the Boost Guidelines. I'm
>> slowly getting used to them. These guidelines are not too strict,
>> there is some variation among different boost libraries. I think
>> Spirit uses such a deviation, indeed to make it clear what is a
>> template. I don't know why, the CamelCase is unique and clear enough
>> (now that typedefs are or will be in lower case). Spirit also has the
>> _t postfix for typedefs, which is also a bit too much for me.
>
> Barend, Bruno,
>
> I've applied some refactoring to ggl/geometries/* and for instance, for
> polygon class, I decided to use _type postifx for typedef declarations.
> I'm not sure about it, however.
>
> I thought it makes sense to distinct class name of alias name,
> especially name of public alias. Also, std library uses _type
> postfix for aliases exposed as public interface of a class.
>
> For example, I changed "B" alias this way:
>
> template <typename P, std::size_t C, std::size_t D>
> struct indexed_access<box<P>, C, D>
> {
>
> typedef box<P> box_type;
> };
>
> What do you think about it?
>
> As I've said, for now I cleaned up ggl/geometries, not more.
> But if we accept this suffix, then I'll use it in other modules.

One more thing, as these aliases are public, we should expect
that some users may want to use it in their code.
Thus, I believe it's worth to work out some convention used across the
code. So, users can familiarize with code easier and public
aliases won't change in future.

Summary:

1. tags use ::type as alias name, for instance:

template <typename P>
struct tag< box<P> >
{
    typedef box_tag type;
};

2. all other public aliases use _type postfix, as in the example
in my previous post (above).

How do you find it?

Best regards,

-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org

Geometry list run by mateusz at loskot.net