2017-11-30 12 views
0

コンパイルエラーを投げています。GMOCK方法は

error: use of deleted function 'std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = message; _Dp = std::default_delete<message>]' 
      MOCK_METHOD2(ship, void (std::shared_ptr<route>, std::unique_ptr<message, std::default_delete<message> >)); 
      ^
     In file included from C:/tools/mingw64/x86_64-w64-mingw32/include/c++/memory:81:0, 
     ...................................................................................... 
     C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/unique_ptr.h:356:7: note: declared here 
       unique_ptr(const unique_ptr&) = delete; 
    error: initializing argument 2 of 'R testing::internal::FunctionMocker<R(A1, A2)>::Invoke(A1, A2) [with R = void; A1 = std::shared_ptr<route>; A2 = std::unique_ptr<message>]' 
     R Invoke(A1 a1, A2 a2) { 
     ^
    In file included from ... 

    C:/tools/mingw64/x86_64-w64-mingw32/include/c++/tuple: In instantiation of 'constexpr std::_Head_base<_Idx, _Head, false>::_Head_base(const _Head&) [with long long unsigned int _Idx = 1ull; _Head = std::unique_ptr<message>]': 
    C:/tools/mingw64/x86_64-w64-mingw32/include/c++/tuple:255:44: recursively required from 'constexpr std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Tuple_impl(const _Head&, const _Tail& ...) [with long long unsigned int _Idx = 1ull; _Head = std::unique_ptr<message>; _Tail = {}]' 
    C:/tools/mingw64/x86_64-w64-mingw32/include/c++/tuple:255:44: required from 'constexpr std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Tuple_impl(const _Head&, const _Tail& ...) [with long long unsigned int _Idx = 0ull; _Head = std::shared_ptr<cmb::mim::MimChannel>; _Tail = {std::unique_ptr<message, std::default_delete<message> >}]' 
    C:/tools/mingw64/x86_64-w64-mingw32/include/c++/tuple:531:30: required from 'constexpr std::tuple<_T1, _T2>::tuple(const _T1&, const _T2&) [with _T1 = std::shared_ptr<cmb::mim::MimChannel>; _T2 = std::unique_ptr<message>]' 
    C:/work/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h:122:50: required from 'R testing::internal::FunctionMocker<R(A1, A2)>::Invoke(A1, A2) [with R = void; A1 = std::shared_ptr<cmb::mim::MimChannel>; A2 = std::unique_ptr<message>]' 
    C:/work/Mock.hpp:39:5: required from here 
    C:/tools/mingw64/x86_64-w64-mingw32/include/c++/tuple:134:25: error: use of deleted function 'std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = message; _Dp = std::default_delete<message>]' 
      : _M_head_impl(__h) { } 

エラーの内容と修正方法がわかりません - MOCKメソッドの宣言をコメントしたり削除したりするとコンパイルは正常に行われますか?

答えて

0

私は、後述するように機能を操作することで問題を解決することができた:

MOCK_METHOD2(myfuncproxy, void (std::shared_ptr<route>, message&)); 

void myfunc((std::shared_ptr<route> r, std::unique_ptr<message, std::default_delete<message> > m) 
{ 
myfuncproxy(r,*m.get()); 
} 
関連する問題