Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3349190
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:38:02+00:00 2026-05-18T01:38:02+00:00

we’re defining some C++ coding style guidelines based on these guidelines . Number 8

  • 0

we’re defining some C++ coding style guidelines based on these guidelines. Number 8 says “Names representing template types should be a single uppercase letter.” Explanation: “Common practice in the C++ development community. This makes template names stand out relative to all other names used.”

Is it really that common? I agree that it makes a lot of sense to have template<class T> class vector {...}. But what if I have several template Arguments? I don’t think that <class A, class B> is easier to understand than <class AllocationPolicy, class ThreadingPolicy>.

Do you agree that there are often cases when the given rule should not be applied (which is allowed according to 1…)?

Thanks for you thoughts!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:38:02+00:00Added an answer on May 18, 2026 at 1:38 am

    I don’t really agree with that naming convention. For me, template parameters representing a fully generic type make sense as a simple letter –this is a type T, I don’t really care which. But if there is any requirements on the type, it makes sense to produce a name that identifies what the template argument is: template <typename T, typename Allocator> struct container — the first type is generic, any T will fit, but the second one is an allocator.

    It is no different to functions, where you do not want your parameters to be called a, b… in order or appearance, but rather produce meaningful names as part of the documentation. Also, if developing a style guide, I would consider requiring local typedefs of the template arguments in the case of template classes together with static asserts on the requirements for the types (whenever possible). That is, at least until concepts provide that functionality.

    I consider the STL to be a good example of library and you can see that generating typedefs help in reading the code (from g++ 4.2 stl):

    Classes:

    // from <vector> -> <bits/stl_vector.h>
    template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
    class vector : protected _Vector_base<_Tp, _Alloc>
    {
      // Concept requirements.
      typedef typename _Alloc::value_type _Alloc_value_type; // _Alloc contains value_type internal type
      __glibcxx_class_requires(_Tp, _SGIAssignableConcept)   // _Tp is assignable
    [...]
    public:
       typedef _Tp value_type;                 // from here on _Tp is not mentioned
       typedef typename _Tp_alloc_type::reference reference; // check + typedef
    [...]
       iterator begin() { 
       // without typedef:
       // __gnu_cxx::__normal_iterator<pointer, vector_type> begin() {
    [...]
       reference operator[](size_type __n)
       // _Tp& operator[](size_type __n)
    [...]
    
    // from <memory>
    template <typename _Tp>
    class auto_ptr 
    {
    [...]
        template <typename _Tp1>
        auto_ptr(auto_ptr<_Tp1>& __a) throw() 
    

    And functions:

    template <typename _InputIterator, typename _Tp>
    inline _InputIterator find( _InputIterator __first, _InputIterator __last, _Tp value ) {
      // concept requirements
      __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
      [...]
    

    All of their names are prefixed by _ and either a capital letter or a second _, which are the names reserved for the implementation, and they prefer _Tp over _T, but at the end you can see that whenever a type is generic it is called _Tp, _Tp1…, while when it has some specific requirements attached, a more sensible name is chosen.

    There is a fine line in between them, as for example in std::vector, there are actual requirements on the generic type: _Tp must be assignable, but at the end of the day, it is a mostly generic type. Calling it _Assignable would be weird in some containers where there are more than one requirement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.