2014-07-10 101 views

回答

6

目的是爲那些元組具有引用的元組,如通過創建std::forward_as_tuple

Foo x; 
Bar y(1, 2, true); 

std::pair<A, B> p(std::piecewise_construct, 
        std::forward_as_tuple(10, x, make()), 
        std::forward_as_tuple(std::move(y), false, get(), 'a')); 

此構建體對元件彷彿由A(10, x, make())

實際的元組類型是std::tuple<int &&, Foo &, Z &&>等,這是重量輕。

+0

恩,我出去了嗎? C++ 11標準允許我們定義對引用的引用?像這樣int && a; ?? –

+0

@志偉晨no no no no no ....查找「r值參考」來找出'&&'的含義。它意味着一個特定的事物,但不是參考的參考。 –

+0

@DrewDormann好吧,我落後於C++ 11 –

相關問題