On 07/12/2017 07:13 AM, Trevor Saunders wrote:
On Tue, Jul 11, 2017 at 11:24:45AM -0400, David Malcolm wrote:+/* Some tokens naturally come in pairs e.g.'(' and ')'. + This class is for tracking such a matching pair of symbols. + In particular, it tracks the location of the first token, + so that if the second token is missing, we can highlight the + location of the first token when notifying the user about the + problem. */ + +template <typename token_pair_traits_t>the style guide says template arguments should be in mixed case, so TokenPairTraits, and the _t looks odd to my eyes.+class token_pair +{ + private: + typedef token_pair_traits_t traits_t;I'm not really sure what this is about, you can name it whatever you like as a template argument, and this name seems less descriptive of what its about.
In generic code, a typedef for a template parameter makes it possible to refer to the parameter even when it's a member of a type whose template parameters aren't known (or that's not even a template). In the C++ standard library the naming convention is to end such typedefs with _type (e.g., value_type, allocator_type, etc.) GCC itself makes use of this convention in its hash_table template. (I have no idea if token_pair is ever used in type generic contexts where the typedef is needed.) As an aside, it's interesting to note that names that end in _t are reserved by POSIX, so (purely) pedantically speaking, making use of them for own symbols is undefined (this is probably one of the most commonly abused POSIX requirements; even the C++ standard flagrantly disregards it). Martin
