[C++エラー] Could not find a match for 'std::vector<int,std::allocator<int> >::vector(std::deque<int,std::allocator<int> >::iterator, std::deque<int,std::allocator<int> >::iterator)'.
いきなりですみませんが質問させて下さい。 コンパイラの最適化は考慮に入れないとして、 int func(int i); class X { int mfunc(int); } void main(){ X x; int (*pfunc)(int) = func;
int a = func(1); // 行a int b = pfunc(2); // 行b int c = x.mfunc(3); // 行c } の場合行aとbの実行速度に違いはないと思ってますがcはa,bと 比べて呼び出しにコストがかかるんでしたっけ? それともコストがかかるのは仮想関数呼び出しの時でしたっけ?
15.1 -5- "If the use of the temporary object can be eliminated without changing the meaning of the program except for the execution of constructors and destructors associated with the use of the temporary object, then the exception in the handler can be initialized directly with the argument of the throw expression."
typenameって直後に書いてあるものが型名であることを表すと思ってたんだけど、 gcc version 3.3.1 (cygming special)で以下ようにするとエラーになります。 $ cat test.cpp && g++ test.cpp #include<iostream> #include<string> using namespace std; template< typename Foo > void func( typename Foo val ) { typename Foo res; res = val + val; cout<< res<< endl; } int main(void) { func<int>(774); func<string>( string( "String" ) ); return 0; } test.cpp:4: error: syntax error before `)' token test.cpp: In function `void func(...)': test.cpp:5: error: syntax error before `;' token test.cpp: In function `void func(...) [with Foo = int]': test.cpp:10: instantiated from here test.cpp:6: error: `val' undeclared (first use this function) test.cpp:6: error: (Each undeclared identifier is reported only once for each function it appears in.) test.cpp:6: error: `res' undeclared (first use this function) test.cpp: In function `int main()': test.cpp:11: warning: cannot pass objects of non-POD type `struct std::string' through `...'; call will abort at runtime