c++ - “char const * name() const _WEBSOCKETPP_NOEXCEPT_TOKEN_ {”是什么意思
问题描述
我已经把头撞在墙上一段时间了,现在试图解决这个错误,但我不明白代码在做什么。
这是我坚持的代码。它在说什么?一个返回指针的函数。“const _WEBSOCKETPP_NOEXCEPT_TOKEN_”是什么意思?它是某种定义,如果是,为什么会在这里?
char const * name() const _WEBSOCKETPP_NOEXCEPT_TOKEN_ {
return "websocketpp";
}
这是我进入 VS 的错误代码
● Started at 18:51:08
1>------ Build started: Project: boost_thread_test, Configuration: Debug
x64 ------
1>boost_thread_test.cpp
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\error.hpp(226): error C2259: 'websocketpp::error::category': cannot instantiate abstract class
1>c:\librarys\socket.io-client
-cpp-master\lib\websocketpp\websocketpp\error.hpp(226): note: due to following members:
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\error.hpp(226): note: 'const char *std::error_category::name(void) noexcept const': is abstract
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\frame.hpp(831): warning C4267: '=': conversion from 'size_t' to 'uint32_t', possible loss of data
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\processors\base.hpp(165): error C2694: 'const char *websocketpp::processor::error::processor_category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\processors\base.hpp(165): note: see declaration of 'websocketpp::processor::error::processor_category::name'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\base\connection.hpp(187): error C2694: 'const char *websocketpp::transport::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\base\connection.hpp(187): note: see declaration of 'websocketpp::transport::error::category::name'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\common\md5.hpp(367): warning C4267: '+=': conversion from 'size_t' to 'websocketpp::md5::md5_word_t', possible loss of data
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\sha1\sha1.hpp(176): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\iostream\base.hpp(77): error C2694: 'const char *websocketpp::transport::iostream::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\iostream\base.hpp(77): note: see declaration of 'websocketpp::transport::iostream::error::category::name'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\extensions\extension.hpp(65): error C2694: 'const char *websocketpp::extensions::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\extensions\extension.hpp(65): note: see declaration of 'websocketpp::extensions::error::category::name'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\asio\base.hpp(205): error C2694: 'const char *websocketpp::transport::asio::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\asio\base.hpp(205): note: see declaration of 'websocketpp::transport::asio::error::category::name'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\asio\security\base.hpp(107): error C2694: 'const char *websocketpp::transport::asio::socket::socket_category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\asio\security\base.hpp(107): note: see declaration of 'websocketpp::transport::asio::socket::socket_category::name'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>Done building project "boost_thread_test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
● Finished at 18:51:12 (total time 4.27s)
解决方案
根据https://github.com/zaphoyd/websocketpp/blob/master/websocketpp/common/cpp11.hpp
看起来它主要是noexcept
.
这基本上意味着该函数不会引发任何异常。
该函数返回一个指向 const char 的 const 指针。这意味着你不能改变指针,也不能改变它指向的东西。
推荐阅读
- javascript - 将值从一个组件传递到另一个 React
- mql4 - 使用 INIT_FAILED 或 INIT_PARTERS_INCORRECT 时,在 MT StrategyTester 优化模式下未找到解决方案
- reactjs - 用多种布局反应路线,重新渲染?
- orientdb - Nexus Repository 版本 3.1 中的 OrientDB 损坏
- visualization - 使用Graphviz中的neato引擎对具有单例/未连接节点的子图进行聚类
- python - Gitlab:使用 CI 使用 pylint 检查提交的 Python 文件
- angular - 如何编辑 ng-template 以使用我的 HTML?
- jquery - 复选框位于标签顶部而不是标签左侧
- python - 根据该数组中的值将值插入到 numpy 数组中
- ios - 如何在 ArKit iOS 中从 3D 点转换 2D 点