如果我有这样的模板类规范,
template <typename T>
class MyClass {
public:
void fun1();
// ...
void funN();
};
template <typename T>
void MyClass<T>::fun1() {
// definition
}
// ...
template <typename T>
void MyClass<T>::funN() {
// definition
}
Run Code Online (Sandbox Code Playgroud)
如果我将类模板更改为其他模板,请说我添加了一个额外的参数:
template <typename T, typename U>
class MyClass {
// ...
};
Run Code Online (Sandbox Code Playgroud)
然后我必须更改每个函数定义(fun1,...,funN)以同意类模板规范:
template <typename T, typename U>
void MyClass<T,U>::fun1() { //... }
Run Code Online (Sandbox Code Playgroud)
有什么策略可以避免这种情况吗?我可以使用宏吗?
#define DFLT_TEMPLATE template<typename T, typename U>
#define DFLT_CLASS class<T,U>
DFLT_TEMPLATE
void DFLT_CLASS::fun1() { // ... }
Run Code Online (Sandbox Code Playgroud)
或者这被认为是不好的做法?
我正在HP Pavilion dm1 4200sg上网本上运行Ubuntu 12.04 studio。这几乎是全新安装。我尝试通过运行启动Jackd服务器
jackd -R -d alsa
Run Code Online (Sandbox Code Playgroud)
它失败,输出:
JACK server starting in realtime mode with priority 10
control device hw:0
control device hw:0
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:0|hw:0|1024|2|48000|0|0|nomon|swmeter|-|32bit
control device hw:0
ALSA: Cannot open PCM device alsa_pcm for playback. Falling back to capture-only mode
Cannot initialize driver
JackServer::Open() failed with -1
Failed to open server
Run Code Online (Sandbox Code Playgroud)
运行aplay -l给出以下输出:
**** List of PLAYBACK Hardware Devices ****
card 0: Generic [HD-Audio Generic], device 3: HDMI …Run Code Online (Sandbox Code Playgroud)