Boost logo

Geometry :

Subject: [ggl] Reviewing GGL against Boost requirements
From: Barend Gehrels (Barend.Gehrels)
Date: 2009-04-20 06:48:11


>
>> One thing about 80 characters: this guideline in much more easy to
>> follow when namespaces are not indented. It's the case in a lot of
>> Boost code and it's quite accepted in the C++ community. So given the
>> number of nested namespaces we sometimes have in GGL we could do that
>> as well. I've never noticed any particular problem of readability in
>> code I've written that way.
>
> So, we're going to not to indent code on namespace level, right?

OK.

> namespace a {
>
> class T
> {
> public:
> void foo();
> protected:
> void bar();
> private:
> std::size_t count_;
> };
>
> } // namespace a

Few things about this:
- I prefer a struct above a class because, especially in templates, many
is public, often there is no protected / private at all
- T in lowercase
- I've always used the m_ prefix for member variables, don't know where
it comes from. Find them much more readable. The boost sample header
gives no prefix/suffix at all. However, the m_ prefix is used in some
(not many) boost libraries as well (e.g. math/tools/remez). So here I
prefer to keep them, at least in this refactoring round
- In case of a template, I prefer the "typename" above the "class"
(unless, of course, if it is required as in template template parameters)

So new proposal:
namespace a {

template <typename T>
struct sample
{
    void foo();
protected:
    void bar();
private:
    std::size_t m_count;
};

} // namespace a

Regards, Barend


Geometry list run by mateusz at loskot.net