You want to map the source iterator from the adapted iterator with .base():
Container::iterator it =
boost::max_element(bar | boost::adaptors::filtered(isRegex))
.base();
Also, may I suggest fixing the naming of your predicate to say what it means:
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <list>
using namespace boost::adaptors;
struct IsMatch {
IsMatch(const boost::regex &rx = boost::regex()) : m_rx(rx) {}
bool operator() (const std::string &str) const {
return boost::regex_match(str, m_rx);
}
private:
boost::regex m_rx;
};
int main()
{
std::string foo[] = {"0ii", "22", "48", "555", "15", "ab"};
typedef std::list<std::string> Container;
Container const bar(foo, foo+5);
IsMatch isMatch(boost::regex("\\d{2}"));
Container::const_iterator it = boost::max_element(bar | filtered(isMatch)).base();
}