[英]How to document functions that are enabled with SFINAE with Doxygen?
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()
. 我只想记录下一个,而且,如果可能的话,我想在Doxygen中将其显示为
constexpr std::size_t v()
。 For the user, the templates here have not value at all. 对于用户而言,此处的模板根本没有价值。
Is that kind of thing possible with Doxygen ? Doxygen有可能发生这种情况吗?
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
You may use \\fn
: http://www.doxygen.nl/manual/commands.html#cmdfn 您可以使用
\\fn
: http : //www.doxygen.nl/manual/commands.html#cmdfn
Something like: (untested) 像这样:(未经测试)
/*! \fn template<typename T> constexpr std::size_t v()
* \brief A function.
* \return 1 or T::V.
*/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.