How to document functions that are enabled with SFINAE with Doxygen?
c++, doxygen, templates
Solution
You can put the function you'd like to see in a conditional section like so:
#ifdef DOXYGEN_ONLY
/*! documentation for v. */
constexpr std::size_t v();
#else // actual implementation with two variants selected via SFINAE
template<typename T = P, enable_if_c<has_V_field<T>> = detail::dummy>
constexpr std::size_t v(){
return T::V;
}
template<typename T = P, disable_if_c<has_V_field<T>> = detail::dummy>
constexpr std::size_t v(){
return 1;
}
#endif
and then use the following configuration settings:
ENABLE_PREPROCESSING = YES
PREDEFINED = DOXYGEN_ONLY
Problem
In a library I'm developing, I often have this kind of code: ``` template<typename T = P, enable_if_c<has_V_field<T>> = detail::dummy> constexpr std::size_t v(){ return T::V; } template<typename T = P, disable_if_c<has_V_field<T>> = detail::dummy> constexpr std::size_t v(){ return 1; } ``` The two functions do the same thing, but are enabled based on the type. I'd like to document only one of then and moreover, I would like if possible to show it in Doxygen without the template stuff, as `constexpr std::size_t v()`. For the user, the templates here have not value at all. Is that kind of thing possible with Doxygen ?