引数の有無が混同する関数オブジェクトの boost::result_of

次の関数オブジェクトで、boost::result_of を使用すると戻り値型がうまく取得出来ずに、コンパイルエラーになります。

struct object{
    template<typename F>
    struct result;
    
    // 引数がない場合に呼んで欲しい
    template<typename F>
    struct result<F()>{
        typedef int type;
    };
    template<typename F>
    struct result<F(int)>{
        typedef float type;
    };
    int operator()(){
        return 0;
    }
    float operator()(int){
        return 0.0f;
    }
};

// ここでコンパイルエラー
BOOST_STATIC_ASSERT(( boost::is_same<
    boost::result_of<object()>::type,
    int  // void
>::value ));

// こっちは成功
BOOST_STATIC_ASSERT(( boost::is_same<
    boost::result_of<object(int)>::type,
    float
>::value ));

これは、引数がない場合に、boost::result_of は、T::result_type を優先して、戻り値型の取得を行うのが原因です。
上記のコードで、上の方の boost::result_of は、void 型が返ってきます。


同様の理由で次のコードもエラーになります。

BOOST_STATIC_ASSERT(( boost::is_same<
    boost::result_of<decltype(boost::lambda::constant(10))()>::type,
    int	// void
>::value ));


[boost]
ver 1.46.1
[参照]
http://www.boost.org/doc/libs/1_46_1/libs/utility/utility.htm#result_of
http://www.kijineko.co.jp/tech/tr1/function-objects/result_of.html