第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

用于在模板類中顯式專門化模板函數(shù)的C ++語(yǔ)法?

用于在模板類中顯式專門化模板函數(shù)的C ++語(yǔ)法?

C++
千萬(wàn)里不及你 2019-10-18 13:46:14
我有在VC9(Microsoft Visual C ++ 2008 SP1)中有效的代碼,但在GCC 4.2(在Mac上)中無(wú)效:struct tag {};template< typename T >struct C{       template< typename Tag >    void f( T );                 // declaration only    template<>    inline void f< tag >( T ) {} // ERROR: explicit specialization in};                               // non-namespace scope 'structC<T>'我知道GCC希望我將顯式專業(yè)移至類之外,但我無(wú)法弄清楚語(yǔ)法。有任何想法嗎?// the following is not correct syntax, what is?template< typename T >template<>inline void C< T >::f< tag >( T ) {}
查看完整描述

3 回答

?
一只名叫tom的貓

TA貢獻(xiàn)1906條經(jīng)驗(yàn) 獲得超3個(gè)贊

如果沒(méi)有顯式地專門化包含類,就不能專門化成員函數(shù)。

但是,您可以做的是向前調(diào)用部分專用類型的成員函數(shù):


template<class T, class Tag>

struct helper {

    static void f(T);   

};


template<class T>

struct helper<T, tag1> {

    static void f(T) {}

};


template<class T>

struct C {

    // ...

    template<class Tag>

    void foo(T t) {

        helper<T, Tag>::f(t);

    }

};


查看完整回答
反對(duì) 回復(fù) 2019-10-18
?
拉莫斯之舞

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超10個(gè)贊

我知道這可能無(wú)法滿足您的要求,但是我不認(rèn)為您可能沒(méi)有在非明確的專業(yè)結(jié)構(gòu)中包含專業(yè)化知識(shí)。


template<>

template<>

inline void C< tag1 >::foo< tag2 >( t_type ) {}


查看完整回答
反對(duì) 回復(fù) 2019-10-18
  • 3 回答
  • 0 關(guān)注
  • 542 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)