Eric Niebler <eric <at> boostpro.com> writes:
On 6/16/2010 3:04 AM, Alex Dubov wrote:
Greetings.
However, if functor is wrapped with assertion, this won't work:
sregex r = (expr)[check(do_something(p_string, _))];
Compilation will fail, because do_something has no method which accepts xpressive::placeholder<> objects.
It should if it is a lazy function. How is do_something defined? Can you send a self-contained program that demonstrates the problem you're having?
I'm using boost-1.41 and gcc-4.4.2. The error I'm receiving compiling an example: -------------------------------------------------------------------- testreg1.cpp:51: instantiated from here /usr/include/boost/proto/context/default.hpp:426: error: no match for call to ‘(const check_a_impl) (const boost::xpressive::detail::action_arg<int, mpl_::int_<0> >&, const int&)’ testreg1.cpp:24: note: candidates are: bool check_a_impl::operator()(int&, int) const Here goes a problematic example itself: -------------------------------------------------------------------- #include <iostream> #include <boost/xpressive/regex_actions.hpp> #include <boost/xpressive/xpressive_static.hpp> using namespace std; using namespace boost::xpressive; const placeholder<int> _cnt = {{}}; struct count_a_impl { typedef void result_type; void operator()(int &cnt) const { ++cnt; } }; function<count_a_impl>::type const count_a = {{}}; struct check_a_impl { typedef bool result_type; bool operator()(int &cnt, int val) const { ++cnt; return (cnt == val); } }; function<check_a_impl>::type const check_a = {{}}; int main(int argc, char **argv) { int cnt = 0; string a_str("a_aaaaa___a_aa_aaa_"); const sregex expr1(*(as_xpr('a')[count_a(_cnt)] | _)); const sregex expr2(*(as_xpr('a')[check(check_a(_cnt, 5))] | _)); /* ^ this check() causes a problem */ sregex_iterator iter1(a_str.begin(), a_str.end(), expr1, let(_cnt = cnt)); cout << "expr1 matched: " << iter1->str(0) << " counted " << cnt << endl; cnt = 0; sregex_iterator iter2(a_str.begin(), a_str.end(), expr2, let(_cnt = cnt)); cout << "expr2 matched: " << iter2->str(0) << " counted " << cnt << endl; return 0; }