【发布时间】:2014-01-16 16:57:26
【问题描述】:
我在编译代码时遇到问题。
template<class InputIterator, class UnaryPredicate>
bool all_of (InputIterator first, InputIterator last, UnaryPredicate pred)
{
while (first!=last) {
if (!pred(*first)) return false;
++first;
}
return true;
}
我从http://www.cplusplus.com/reference/algorithm/all_of/?kw=all_of获取代码。
我正在使用 Code::blocks 12.11,但出现以下错误:
C:\Users\PC-HP\Desktop\chiffre\romain\main.cpp||在 'bool all_of(InputIterator, InputIterator, UnaryPredicate) 的实例化中 [with InputIterator = __gnu_cxx::__normal_iterator >; UnaryPredicate = bool (*)(std::basic_string)]':|
C:\Users\PC-HP\Desktop\chiffre\romain\main.cpp|84|从这里需要|
C:\Users\PC-HP\Desktop\chiffre\romain\main.cpp|13|错误:从 'char' 到 'const char*' 的无效转换 [-fpermissive]|
c:\program files\codeblocks\mingw\bin..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.tcc|214|错误:初始化 'std::basic_string 的参数 1 <_chart _traits _alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator]' [-fpermissive]|
||=== 构建完成:2 个错误,2 个警告(0 分钟,1 秒)===|
第 84 行:
while(!all_of(romain.begin(), romain.end(), IsRoman))
这是我的完整代码:http://pastebin.com/k0KYNB6H
我不使用c++11。
【问题讨论】:
-
romain的类型是什么?
标签: c++