Doxygen: C++: mishandling of brackets used in trailing return types

Created on 7 Sep 2020  路  3Comments  路  Source: doxygen/doxygen

Describe the bug
Doxygen appears to be getting confused with brackets used in trailing return types. Switching from brackets to parenthesis makes the problems go away and appears to be a work around while this bug remains.

The decltype trailing return type in the following code for example appears to be confusing Doxygen causing it to miss reporting the closing parenthesis on the decltype(...) and causing it to emit an Initial value code snippet:

/// @brief Constrained value equality operator or value types which support it.
/// @tparam LhsValueType Type of the value used by the left hand side checked value.
/// @tparam LhsCheckerType Type of the checker used by the left hand side checked value.
/// @tparam RhsValueType Type of the value used by the right hand side checked value.
/// @tparam RhsCheckerType Type of the checker used by the right hand side checked value.
/// @relatedalso CheckedValue
template <typename LhsValueType, typename LhsCheckerType, typename RhsValueType, typename RhsCheckerType>
constexpr auto operator== (const CheckedValue<LhsValueType, LhsCheckerType>& lhs,
                           const CheckedValue<RhsValueType, RhsCheckerType>& rhs)
    noexcept(noexcept(std::declval<LhsValueType>() == std::declval<RhsValueType>()))
-> decltype(LhsValueType{lhs} == RhsValueType{rhs})
{
    return LhsValueType{lhs} == RhsValueType{rhs};
}

Expected behavior
Doxygen handles trailing return types such as decltype(LhsValueType{lhs} == RhsValueType{rhs}) by properly recognizing the bracket syntax as being similar to parenthesis syntax.

Screenshots
Screen Shot Doxygen Documentation Issue

To Reproduce
Append the previously mentioned code into a file after a definition of CheckedValue like the following:

template <typename T>
struct NoOpChecker
{
    constexpr auto operator()() noexcept -> decltype(T())
    {
        return T();
    }

    constexpr auto operator()(T v) noexcept -> decltype(T(v))
    {
        return v;
    }
};

template <typename ValueType, typename CheckerType = NoOpChecker<ValueType>>
class CheckedValue
{
public:
    using value_type = ValueType;
    using checker_type = CheckerType;

    constexpr CheckedValue(value_type value) noexcept(noexcept(checker_type{}(value))):
        m_value{CheckerType{}(value)}
    {
    }

    constexpr operator value_type () const noexcept
    {
        return m_value;
    }

private:
    value_type m_value; ///< Underlying value.
};

Version
1.8.20.

C++11 C++ bug

Most helpful comment

Code has been integrated in master on github (please don't close the issue as this will be done at the moment of an official release).

All 3 comments

I've just pushed a proposed patch, pull request #8019

Code has been integrated in master on github (please don't close the issue as this will be done at the moment of an official release).

This issue was previously marked 'fixed but not released',
which means it should be fixed in doxygen version 1.9.0.
Please verify if this is indeed the case. Reopen the
issue if you think it is not fixed and please include any additional information
that you think can be relevant (preferably in the form of a self-contained example).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Alphastrick picture Alphastrick  路  6Comments

KantarBruceAdams picture KantarBruceAdams  路  5Comments

silvester747 picture silvester747  路  6Comments

aster94 picture aster94  路  3Comments

eseiler picture eseiler  路  4Comments