5
我知道這不是一個非常尖銳的問題。是否有優勢(編譯時間,依賴關係,調試符號大小,可用性,可讀性等)使用一個優先?繼承自std :: true_type vs static constexpr const布爾成員
template < typename T >
struct IsSharedPtr : std::false_type
{
};
VS
template < typename T >
struct IsSharedPtr
{
static constexpr bool value = false;
};
一個相關的問題...
template < typename T, typename Enabler >
struct S;
template < typename T >
struct S < T, std::true_type >{};
template < typename T >
struct S < T, std::false_type >{};
VS
template < typename T, bool enabler >
struct S;
template < typename T >
struct S < T, true >{};
template < typename T >
struct S < T, false >{};
注意你也可以派遣上第二個模板參數,這可能是有點嚴格,因爲類型(特徵)轉換不涉及選擇功能。 – rubenvb