2017-07-03 6 views
0

ビルドしようとしているサードパーティライブラリのテンプレート関数でエラーが発生しています。テンプレートのインスタンス化/タイプ控除からのエラーメッセージの実際のソースの検索

MSVCは関数を指し、特定の呼び出しに対して何か間違っていると言いました。正確にエラーが発生したコールをどのように知ることができますか?


それが重要ならば、これは関数である。

template <typename T> 
std::string ToString(T number) { 
    std::ostringstream ss; 
    ss << std::setprecision(NUM_TO_STRING_PRECISION); 
    ss << number; 
    return ss.str(); 
} 

エラーは次のとおりです。

エラーC2088 '< <':クラス

+0

これは完全なエラーですか? –

+0

@RetiredNinja Yup –

+0

ドキュメントでは、エラーはCコードでのみ発生すると言います。 https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2088使用場所はいくつですか?それを引き起こすものが見つかるまで、あなたはそれらをコメントアウトし始めるかもしれません。 –

答えて

1
のための違法

どのように私はwで知ることができますか?エラーが発生した場合は正確に呼び出されますか?

そうでもない、しかし、簡単なexampleを見てみましょう:これらのエラーメッセージを出力++

#include <vector> 

struct Foo { 
    Foo() = delete; 
}; 

int main() { 
    std::vector<Foo> vfoo(15); 
    (void)vfoo; 
} 

GCCのG:

In file included from /usr/local/include/c++/7.1.0/vector:63:0, 
       from main.cpp:1: 
/usr/local/include/c++/7.1.0/bits/stl_uninitialized.h: In instantiation of 'static _ForwardIterator std::__uninitialized_default_n_1<true>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = Foo*; _Size = long unsigned int]': 
/usr/local/include/c++/7.1.0/bits/stl_uninitialized.h:583:20: required from '_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = Foo*; _Size = long unsigned int]' 
/usr/local/include/c++/7.1.0/bits/stl_uninitialized.h:645:44: required from '_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, std::allocator<_Tp>&) [with _ForwardIterator = Foo*; _Size = long unsigned int; _Tp = Foo]' 
/usr/local/include/c++/7.1.0/bits/stl_vector.h:1347:36: required from 'void std::vector<_Tp, _Alloc>::_M_default_initialize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = Foo; _Alloc = std::allocator<Foo>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 
/usr/local/include/c++/7.1.0/bits/stl_vector.h:285:30: required from 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = Foo; _Alloc = std::allocator<Foo>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<Foo>]' 
main.cpp:9:29: required from here 
/usr/local/include/c++/7.1.0/bits/stl_uninitialized.h:548:37: error: use of deleted function 'Foo::Foo()' 
    return std::fill_n(__first, __n, _ValueType()); 
            ^~~~~~~~~~~~ 
main.cpp:4:5: note: declared here 
    Foo() = delete; 
    ^~~ 

はIIRC、それはVisual Studioで非常に似ています。生の出力タブを開いて、最後のnoteに行きます。おそらく実際のソースのエラーが含まれています。


MSVCはrextesterとなります。最後に、source_file.cppの最後の注記は、エラーの本当の原因を指しています。

+0

本当にありがとうございます。あなたの答えで解決しました –

+0

@HumamHelfawi De nada ;-) – user0042

関連する問題