2006-11-02から1日間の記事一覧

コピーを伴わずに左辺値->右辺値変換を行う

C++

template< class T > T f( T &x ) { return true ? x : f( x ); }上記のコード片中の3項演算子の計算結果は右辺値だが,依然としてオブジェクト x を指し続けている(つまりコピーが行われない). 5.16 Conditional operator 3 Otherwise, if the second an…

関数テンプレートにおける右辺値識別

完全に個人的なメモなので気にしないよ〜に. #include <iostream> #include <boost/mpl/identity.hpp> #include <boost/mpl/if.hpp> #include <boost/type_traits/is_volatile.hpp> #include <boost/static_assert.hpp> struct volatile_refused; template< class T, class R = void > struct refuse_volatile : public boost::mpl::if_< boost:…</boost/static_assert.hpp></boost/type_traits/is_volatile.hpp></boost/mpl/if.hpp></boost/mpl/identity.hpp></iostream>