使用GCC,可以打印出-march=native触发的特定标志.是否有可能让Clang打印类似的信息?
我用std :: mt19937_64生成一系列随机数.我注意到,当使用相同的种子在同一平台上运行GCC和Clang时,我获得了不同的序列.我通过Valgrind运行程序,发现没有未初始化的内存.
使用std :: mt19937_64是否可以保证编译器或跨平台的可重复性?
编辑:使用std :: normal_distribution运行
根据cppreference和这个答案,C++应该不自动,如果有一个用户声明析构函数生成一个移动构造函数.但是,在实践中用Clang检查这个,我看到了一个自动生成的移动构造函数.以下代码打印"is_move_constructible:1":
#include <iostream>
#include <type_traits>
struct TestClass
{
~TestClass()
{}
};
int main( int argc, char** argv )
{
std::cout << "is_move_constructible: " << std::is_move_constructible<TestClass>::value << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
我误解"没有用户声明的析构函数"或std :: is_move_constructible吗?我正在使用'-std = c ++ 14'和Apple LLVM版本7.0.2(clang-700.1.81)进行编译.
是否可以将析构函数声明为纯虚拟并使用default关键字?例如,我似乎无法使代码像这样工作:
class MyClass
{
public:
// Is there a way to combine pure virtual and default?
virtual ~ MyClass() = 0,default;
};
Run Code Online (Sandbox Code Playgroud)
人们当然可以稍后做:
MyClass::~ MyClass() = default;
Run Code Online (Sandbox Code Playgroud)
此外,如果析构函数不是纯虚拟的,则默认关键字在声明后面会起作用.