当我有一个看起来像这样的代码:
template<class T>
void f_(const T& arg)
{
cout << "void f(const T& arg): Cannot modify\n";
}
template<class T>
void f_(T&& arg)
{
cout << "void f(T&& arg): Can modify\n";
}
Run Code Online (Sandbox Code Playgroud)
在主要我称之为:
int main()
{
MemoryBlock block;
f_(block);
f_(MemoryBlock());
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出为:
"void f(T && arg):可以修改\n";
"void f(T && arg):可以修改\n";
但是,当我将此代码更改为非泛型时,而不是函数模板,我将具有常规函数,
void f(const MemoryBlock&)
{
cout << "In f(const MemoryBlock&). This version cannot modify the parameter.\n";
}
void f(MemoryBlock&&)
{
cout << "In f(MemoryBlock&&). This version can modify the …Run Code Online (Sandbox Code Playgroud) 当我在我的项目(Visual Studio 2015 Update 1)中尝试使用Visual Codegen的新clang时,我收到以下错误:
clang.exe : error : cannot specify -o when generating multiple output files
Run Code Online (Sandbox Code Playgroud)
这只是一个新创建的项目,具有自动生成的主要功能.
我真的不知道该怎么办.
任何帮助赞赏.