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

  • Home
  • SEARCH
  • 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 691661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:34:06+00:00 2026-05-14T02:34:06+00:00

When I write class templates, and need to fully-specialize members of those classes, Doxygen

  • 0

When I write class templates, and need to fully-specialize members of those classes, Doxygen doesn’t recognize the specialization – it documents only the generic definition, or (if there are only specializations) the last definition. Here’s a simple example:

===MyClass.hpp===

#ifndef MYCLASS_HPP
#define MYCLASS_HPP

template<class T> class MyClass{
public:
    static void foo();
    static const int INT_CONST;
    static const T TTYPE_CONST;
};

/* generic definitions */
template<class T>
void MyClass<T>::foo(){
    printf("Generic foo\n");
}

template<class T>
const int MyClass<T>::INT_CONST = 5;

/* specialization declarations */
template<> void MyClass<double>::foo();
template<> const int MyClass<double>::INT_CONST;
template<> const double MyClass<double>::TTYPE_CONST;
template<> const char MyClass<char>::TTYPE_CONST;

#endif

=== MyClass.cpp ===

#include "MyClass.hpp"

/* specialization definitions */
template<>
void MyClass<double>::foo(){
    printf("Specialized double foo\n");
}

template<> const int MyClass<double>::INT_CONST = 10;

template<> const double MyClass<double>::TTYPE_CONST = 3.141;
template<> const char MyClass<char>::TTYPE_CONST = 'a';

So in this case, foo() will be documented as printing “Generic foo,” INT_CONST will be documented as set to 5, with no mention of the specializations, and TTYPE_CONST will be documented as set to ‘a’, with no mention of 3.141 and no indication that ‘a’ is a specialized case.

I need to be able to document the specializations – either within the documentation for MyClass<T>, or on new pages for MyClass<double>, MyClass<char>. How do I do this? Can Doxygen even handle this? Am I possibly doing something wrong in the declarations/code structure that’s keeping Doxygen from understanding what I want?

I should note two related cases:

A) For templated functions, specialization works fine, e.g.:

/* functions that are global/in a namespace */
template<class T> void foo(){ printf("Generic foo\n"); }
template<> void foo<double>(){ printf("Specialized double foo\n"); }

This will document both foo<T>() and foo<double>().

B) If I redeclare the entire template, i.e. template<> class MyClass<double>{...};, then MyClass<double> will get its own documentation page, as a seperate class. But this means actually declaring an entirely new class – there is no relation between MyClass<T> and MyClass<double> if MyClass<double> itself is declared. So I’d have to redeclare the class and all its members, and repeat all the definitions of class members, specialized for MyClass<double>, all to make it appear as though they’re using the same template. Very awkward, feels like a kludge solution.

Suggestions? Thanks much 🙂

–Ziv

  • 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-14T02:34:06+00:00Added an answer on May 14, 2026 at 2:34 am

    Further seeking indicates that this issue was an open bug, fixed in Doxygen 1.8.10.

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

Sidebar

Related Questions

When I write C++ code for a class using templates and split the code
I am trying to write a trivial Matrix class, using C++ templates in an
Write a class ListNode which has the following properties: int value; ListNode *next; Provide
When I write a class I always expose private fields through a public property
I'm trying to write a class in Delphi 2007 that uses a ActiveX library.
Would it be possible to write a class that is virtually indistinguishable from an
Ok here's what I'm trying to do I want to write a class that
So, let's say I want to write a class that operates on different kinds
I'm trying to write a small class library for a C++ course. I was
I'd like to write a MessageConverter class that can wrap another MessageConverter. This MessageConverter

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.