どちらがより正しいですか? なぜ。
仕事で、私は最近、特定のテンプレートの専門化を行う方法についての議論に参加しました。
こちらです:
template <typename T, bool someBoolVar = is_polymorphic<T>::value>
struct SomeTemplate { // with empty definition
};
template <typename T>
struct SomeTemplate<T, true> {
...
};
template <typename T>
struct SomeTemplate<T, false> {
...
};
またはこの方法:
template <typename T, bool someBoolVar = is_polymorphic<T>::value>
struct SomeTemplate; // without empty definition -- difference here
template <typename T>
struct SomeTemplate<T, true> {
...
};
template <typename T>
struct SomeTemplate<T, false> {
...
};