[bind10-dev] Should We Use C++ Templates?
JINMEI Tatuya / 神明達哉
jinmei at isc.org
Tue Jul 20 07:53:31 UTC 2010
At Mon, 19 Jul 2010 16:21:18 +0100,
Stephen Morris <stephen at isc.org> wrote:
> At the last BIND-10 teleconference I was asked to review the base_n
> code, and to comment on whether the style - using C++ templates - is
> reasonable or too tricky to share.
Thanks for the thoughts. Some quick comments:
- I agree it's not a 0-1 choice.
- I also agree we should generally provide good documentation, and
this is probably more so if we use non trivial templates.
- I think it's not just about templates. It's also about (relative)
advanced C++ idioms that mainly come with templated
classes/STL/boost. Examples are relatively minor STL methods, STL
algorithm and functor classes. Some people are familiar with these,
but some others aren't; some people don't like using them even if
they are familiar with them; depending on background knowledge these
are just unreadable for some people, while for others it may look
more intuitive and concise. The question is how to find a
reasonable point where all (or at least most) of the main developers
are happy.
Personally, I tried to avoid complicated (which is admittedly a
subjective term) template meta programming. But I sometimes use
templates especially within .cc when it helps reduce duplicate code.
The base_n implementation is in this sense an exception. Admittedly
it's quite tricky, but the tricky part is mainly derived from the
trickyness of the base boost implementation.
On the other hand, I use STL algorithms than traditional C-style loops
more aggressively because I believe once you learn it it's generally
safer in terms of boundary considerations. But I also understand for
some others such idioms are just non-comprehensive code.
---
JINMEI, Tatuya
More information about the bind10-dev
mailing list