2009-06-01から1ヶ月間の記事一覧

N2855 noexceptについて

C++

C++0xの新しい提案でN2855(Rvalue References and Exception Safety)では、noexceptというキーワードが追加されています。 まずはコードから見ます。 noexcept int foo(int); int bar(int); noexcept void wibble(int x, int y) { x = foo(x); // OK: foo()…

練習でstd::reference_wrapperがラップしてる型を取得するメタ関数を作ってみた

C++

std::reference_wrapperの場合は保持してるTを返します。 std::reference_wrapperではない場合は受けた型をそのまま返します。 #include <functional> #include <tuple> namespace mpl { template<class T> struct remove_wrap; { typedef T type; }; template<class T> struct remove_wrap<std::reference_wrapper<T>> { typ</std::reference_wrapper<t></class></class></tuple></functional>…

ユーザ定義リテラルまとめ

C++

このエントリは見事に間違ってたので忘れてください。>< グローバルな名前空間でもユーザ定義リテラルは定義できます。参考 http://cpplover.blogspot.com/2009/09/user-defined-literal.htmlところで新たな疑問があったのでここにメモ。 template <char... C> std::s</char...>…