У меня есть следующий заголовочный файл:
#ifndef LOGIN_STATEMACHINE_EXCEPTION_HPP_
#define LOGIN_STATEMACHINE_EXCEPTION_HPP_
#include "LoginLib/StateMachine/Global.hpp"
#include "LoginLib/Common/Exception.hpp"
#include <string_view>
#include <string>
namespace LoginLib {
namespace StateMachine {
class Exception : public Common::Exception {
public:
LOGINLIB_STATEMACHINE_LIB Exception(std::string_view message);
virtual ~Exception() = default;
};
} // namespace StateMachine
} // namespace LoginLib
#endif // !LOGIN_STATEMACHINE_EXCEPTION_HPP_
///////////////////////////////////////////////////////////////////////////////
// DOCUMENTATION //
///////////////////////////////////////////////////////////////////////////////
/**
* @class LoginLib::StateMachine::Exception
*
* @brief Exception class for state machine library
*
* This is the exception that's raised when the state machine library launches
* an exception.
*/
и следующий cpp файл:
#include "LoginLib/StateMachine/Exception.hpp"
namespace LoginLib {
namespace StateMachine {
///////////////////////////////////////////////////////////////////////////////
// USING SECTION //
///////////////////////////////////////////////////////////////////////////////
using std::string_view;
///////////////////////////////////////////////////////////////////////////////
// PUBLIC SECTION //
///////////////////////////////////////////////////////////////////////////////
/**
* @brief Message constructor.
*
* This constructor allows to define a message that must be associated with the
* exception.
*
* @param[in] message Message that must be set.
*/
Exception::Exception(string_view message) :
Common::Exception(std::string(message)) {
}
} // namespace StateMachine
} // namespace LoginLib
Если я пытаюсь собрать документацию по Doxygen, я получаю следующее предупреждение ( что я управляю как ошибка):
H:/path/Exception.cpp:24: error: no matching class member found for
LoginLib::StateMachine::Exception::Exception(string_view message)
Possible candidates:
LOGINLIB_COMMON_LIB LoginLib::Common::Exception::Exception(const std::string &message)
LOGINLIB_STATEMACHINE_LIB LoginLib::StateMachine::Exception::Exception(std::string_view message)
(warning treated as error, aborting now)
Ошибка исчезнет, если вместо использования string_view
подписи в методе конструктора cpp я поставлю std::string_view
:
#include "LoginLib/StateMachine/Exception.hpp"
namespace LoginLib {
namespace StateMachine {
///////////////////////////////////////////////////////////////////////////////
// USING SECTION //
///////////////////////////////////////////////////////////////////////////////
using std::string_view;
///////////////////////////////////////////////////////////////////////////////
// PUBLIC SECTION //
///////////////////////////////////////////////////////////////////////////////
/**
* @brief Message constructor.
*
* This constructor allows to define a message that must be associated with the
* exception.
*
* @param[in] message Message that must be set.
*/
Exception::Exception(std::string_view message) :
Common::Exception(std::string(message)) {
}
} // namespace StateMachine
} // namespace LoginLib
Очевидно, что это не позволяет мне определять оператор using
, и мне нужно переписать весь код, чтобы поместить пространства имен во все аргументы метода и функции, это то, чего мне нужно избегать. Как я могу сказать doxygen, что string_view
является std::string_view
, и, очевидно, для всех других классов, с которыми я работаю таким же образом?