2011-12-07 2 views
1

非同期(async)私は、GCC 4.6.2でunique_ptrを受け入れる機能を起動するstd::asyncを取得しようとしている:STDとunique_ptrをを取る機能を呼び出す::

#include <type_traits> 
#include <memory> 
#include <functional> 
#include <future> 

struct Foo {}; 

// my gcc does not have this, same definition as in 30.2.6 
template<typename T> 
typename std::decay<T>::type decay_copy(T&& v) { return std::forward<T>(v); } 

int main() { 
    std::function<int(std::unique_ptr<Foo>)> f = [](std::unique_ptr<Foo>) { return 23; }; 

    std::unique_ptr<Foo> fp{new Foo}; 
    std::unique_ptr<Foo> fp2{std::move(fp)}; 
    // works, this seems to satisfy the requirements of async 
    f(decay_copy(std::move(fp2))); 

    // does not work with reference to a deleted function 
    // std::async(f, std::move(fp2)); 
} 

すると、これは正常な動作ですかそれはありますgccのバグ?

答えて

2

おそらくバグです。 g ++ 4.7でコンパイルできます。

関連する問題