小编Aar*_*ron的帖子

模板模板参数可以默认引用其他模板类型参数吗?

我正在尝试做类似以下的事情:

template <typename T>
struct A
{
    template <typename U>
    struct AA
    {
    };
};

template <typename V, template <typename> class W = A<V>::AA> // Causes C3202
struct B
{
};
Run Code Online (Sandbox Code Playgroud)

但Visual Studio 2010编译器吐出:

错误C3202:'AA':模板参数''的默认参数无效,需要一个类模板

如果我用以下模板替换B:

// Replace "T" with "int"
template <typename V, template <typename> class W = A<int>::AA>
struct B
{
};
Run Code Online (Sandbox Code Playgroud)

代码编译得很好,但不是我想要的.如果原始文件不是合法的C++,是否有替代方案为"B"模板的用户提供类似的界面?

c++ templates template-templates

9
推荐指数
1
解决办法
1083
查看次数

如何在不继承子进程中的句柄的情况下使用"start"命令?

这是一个说明我问题的最小例子:

:: test.bat
@echo off
call test2.bat 2>&1 | findstr foo
echo done calling test2

:: test2.bat
@echo off
start /B notepad >NUL
echo done starting child process
Run Code Online (Sandbox Code Playgroud)

在此示例中,在记事本关闭之前,findstr将无法完成,可能是因为记事本已从父cmd进程继承了stdout.如何修改test2.bat以便test.bat不挂起?

windows cmd batch-file

5
推荐指数
1
解决办法
618
查看次数

标签 统计

batch-file ×1

c++ ×1

cmd ×1

template-templates ×1

templates ×1

windows ×1