'noexcept = default'编译错误
'noexcept = default' compilation error
我在尝试编译下面的程序时收到以下错误。应该修改什么才能编译?看起来 GCC 4.9.2 无法实现一些 noexcept 移动构造函数作为"=default"。7号线造成麻烦:TabStats::TabStats(TabStats&& other) noexcept = default;
TabStats::TabStats(resource_coordinator::TabStats&&&)' 不同的异常规范 TabStats::TabStats(TabStats&& other) noexcept = default;
^
源代码:
#include "browser/resource_coordinator/tab_stats.h"
#include "build/build_config.h"
namespace resource_coordinator {
TabStats::TabStats() = default;
TabStats::TabStats(const TabStats& other) = default;
TabStats::TabStats(TabStats&& other) noexcept = default;
TabStats::~TabStats() {}
TabStats& TabStats::operator=(const TabStats& other) = default;
} // namespace resource_coordinator
tab_stats.h包括如下:
#ifndef BROWSER_RESOURCE_COORDINATOR_TAB_STATS_H_
#define BROWSER_RESOURCE_COORDINATOR_TAB_STATS_H_
#include <stdint.h>
#include <vector>
#include "base/process/process.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "build/build_config.h"
namespace content {
class RenderProcessHost;
} // namespace content
namespace resource_coordinator {
struct TabStats {
TabStats();
TabStats(const TabStats& other);
TabStats(TabStats&& other) noexcept;
~TabStats();
TabStats& operator=(const TabStats& other);
bool is_app = false; // Browser window is an app.
bool is_internal_page = false; // Internal page, such as NTP or Settings.
// Playing audio, accessing cam/mic or mirroring display.
bool is_media = false;
bool is_pinned = false;
bool is_in_visible_window = false;
bool is_in_active_window = false;
// Whether this is the active tab in a browser window.
bool is_active = false;
bool is_discarded = false;
// User has entered text in a form.
bool has_form_entry = false;
int discard_count = 0;
bool has_beforeunload_handler = false;
base::TimeTicks last_active;
base::TimeTicks last_hidden;
content::RenderProcessHost* render_process_host = nullptr;
base::ProcessHandle renderer_handle = 0;
int child_process_host_id = 0;
base::string16 title;
#if defined(OS_CHROMEOS)
int oom_score = 0;
#endif
int64_t tab_contents_id = 0; // Unique ID per WebContents.
bool is_auto_discardable = true;
};
typedef std::vector<TabStats> TabStatsList;
} // namespace resource_coordinator
#endif // BROWSER_RESOURCE_COORDINATOR_TAB_STATS_H_
我认为
,问题是编译器无法生成默认noexcept
移动构造函数,因为并非所有类成员都具有noexept
移动构造函数。
例如,下一个代码将不会编译相同的错误:
example::A::A(example::A&&)' 在其重新声明时默认使用与隐式异常规范不同的异常规范
namespace example
{
class B
{
public:
B(B&&);
int mData;
};
B::B(B&&) = default;
class A
{
public:
A(A&&) noexcept;
std::string mData;
B mField;
};
A::A(A&&) noexcept = default;
}
相关文章:
- 用MacOS Mojave编译C++:致命错误:mpi.h:没有这样的文件或目录
- std::is_base_of表示ctor编译错误
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 在没有定义返回类型的函数中返回布尔值,并将结果保存在无错误的char编译中-为什么
- Qt5:使用QCommandLineParser类时出现奇怪的编译错误
- Qt Cmake 错误编译"GuiSupportQt not found"
- Opengl 精度转换错误编译错误 E0415
- 库将ARM架构错误编译为架构X64
- RT 音频 Mac 错误 g++ 编译错误
- 错误编译Boost.log
- 错误编译QT创建者 / QT窗口小部件示例
- 错误编译MIPS32
- Visual Studio 2013 中的错误(编译和运行代码)
- 链接错误编译qt项目在visual 2010
- 无法用模板错误编译nsgmls
- 奇怪的错误.编译失败
- 如果有人调用c++中的方法,则强制错误(编译时)
- 来自autoconf测试的错误编译命令
- 时间限制超出错误C++编译
- SFML 2.3 和 CodeBlocks 错误编译