templates - Doxygen complains about recursive C++ class -
i have simple recursive template implements (the optimised version of) euclid's algorithm. doxygen complains it:
/usr/home/kamikaze/stark/yggdrasil/src/units/units.hpp:335: warning: detected potential recursive class relation between class units::euclid , base class units::euclid< rhs, lhs%rhs >! /usr/home/kamikaze/stark/yggdrasil/src/units/units.hpp:335: warning: detected potential recursive class relation between class units::euclid , base class euclid< rhs, lhs%rhs >! /usr/home/kamikaze/stark/yggdrasil/src/units/units.hpp:335: warning: detected potential recursive class relation between class units::euclid , base class units::euclid< rhs, lhs%rhs >! /usr/home/kamikaze/stark/yggdrasil/src/units/units.hpp:335: warning: detected potential recursive class relation between class units::euclid , base class euclid< rhs, lhs%rhs >!
i'm dumbfounded why complaint/warning. think recursive types common , legal. it's 1 of many recursive templates, 1 doxygen complains about. surprise i've found similar questions doxygen misdetecting recursion.
if you're interested, here code:
/** * implements euclid's algorithm find gcd between 2 integers. * * @tparam lhs,rhs * values gcd */ template <int lhs, int rhs> struct euclid : euclid<rhs, lhs % rhs> { }; /** * terminates euclid's algorithm. * * @tparam gcd * gcd return * @see euclid */ template <int gcd> struct euclid<gcd, 0> { /** * gcd of 2 original values. */ static constexpr int const value{gcd}; };
this construct indeed beyond doxygen's parsing capabilities.
since not interesting user of class know implemented in recursive way, use following workaround:
/** * implements euclid's algorithm find gcd between 2 integers. * * @tparam lhs,rhs * values gcd */ template <int lhs, int rhs> struct euclid /** @cond */ : euclid<rhs, lhs % rhs> /** @endcond */ { /** @cond */ }; template <int gcd> struct euclid<gcd, 0> { /** @endcond * gcd of 2 original values. */ static constexpr int const value {gcd}; };
Comments
Post a Comment