###前提・実現したいこと
c++でデバッグ用の関数を作っているのですが,以下のようなエラーが出てしまい困っています.
###エラーメッセージ
test.cpp:10:9: error: invalid operands to binary expression ('ostream' (aka 'basic_ostream<char>') and 'const std::__1::vector<int, std::__1::allocator<int> >') cerr<<first<<" ";debug(rest...); ~~~~^ ~~~~~
###該当のソースコード
cpp
1#include <iostream> 2#include <sstream> 3#include <vector> 4using namespace std; 5 6inline void debug(){ cerr << endl; } 7 8template<class First, class... Rest> 9void debug(const First& first, const Rest&... rest){ 10 cerr<<first<<" ";debug(rest...); 11} 12 13template<typename T>string join(vector<T>&v, string del=", ") 14{ stringstream s; 15 for (int i = 0; i < v.size(); i++) s<<del<<v[i]; 16 return s.str().substr(del.size()); 17} 18 19template<typename T>ostream& operator<<(ostream& o, vector<T>&v) 20{ 21 if(v.size()) o<<"["<<join(v)<<"]"; 22 return o; 23} 24 25int main(){ 26 vector<int> v; 27 for (int i = 0; i < 8; i++) { 28 v.push_back(i); 29 } 30 debug(v); 31 return 0; 32} 33
###補足情報
コンパイラ: clang++
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
よろしくお願いします.

回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。