
Rob Stewart wrote:
From: Florian Stegner <FlSt@gmx.de>
Rob Stewart wrote:
Nah, like this:
set<int> a; all_values<set<int> > all_of_a(all_of(a));
I've nearly got that ready plus I'm using your dispatch technique. I'll upload it when I get it compiling.
...
2. You don't have iterator range support yet.
This will be the next point I will work on.
Take a look at mine. My next version will follow your dispatch technique, so you might just want to wait for that one.
I will wait. :-)
4. I see that you've made good use of implementing one type in terms of another. I did that early on in my operator intensive version and ignored it after refactoring my library. I need to revisit that.
That was the thing which makes the 10% runtime differences between our implementations without optimizing.
Mine is 10% faster or slower because of that? I've lost track of which is faster now.
Yours was faster. I think my implementation of the do_comparison functions for one_junction, n_junction, injunction and abjunction are the reason.
But now I'm a little bit confused. The precedence must be higher, or I'm wrong? For example someone writes: any_of( a ),equal(),all_of( b ) && any_of( c ),equal(),all_of(d); So all_of( b ) && any_of( c ) will be evaluated before the ",". If you write any_of( a )|equal()|all_of( b ) && any_of( c )|equal()|all_of(d) It will give the correct answer.
That's a good point. I was thinking about the lambda expressions one might write for the predicate. I suppose the use case you've mentioned is more important, so we should have higher precedence than the logical operators.
The operators with the highest precedence we can use are "*" "/" "%".... I think "/" would look fine: all_of( a ) /expr()/ any_of(b). But there is a little problem with lambdas expressions using this operators. I tried following example: any_of( a ) |( lambda::_2 >= lambda::_1 )| all_of( b ). I got an error message from gcc 4.0.1 that the call to the second |-operator is ambiguous, because also lamda implements the | operator. How can this be avoided? The only idea I have is the ","-operator. See below the error message. Antoher point is the naming. I think, after reading a book about logic, that "junction" would be the best name. Error message: junction_example.cpp:166: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: /home/stegner/include/boost/lambda/detail/operators.hpp:117: note: candidate 1: const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::or_action>, boost::tuples::tuple<typename boost::lambda::const_copy_argument<const A>::type, boost::lambda::lambda_functor<Arg>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > > boost::lambda::operator|(const A&, const boost::lambda::lambda_functor<Arg>&) [with A = boost::junctions::junction<boost::junctions::detail::n_m_junction<2u, 3u, std::set<std::string, std::less<std::string>, std::allocator<std::string> > > >, Arg = boost::lambda::lambda_functor_base<boost::lambda::relational_action<boost::lambda::greaterorequal_action>, boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<2>
, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >] /home/stegner/include/boost/junctions/junction.hpp:76: note: candidate 2: boost::junctions::detail::partial_expr<JunctionType, Predicate> boost::junctions::junction< <template-parameter-1-1> >::operator|(const Predicate&) const [with Predicate = boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::relational_action<boost::lambda::greaterorequal_action>, boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<2> , boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >, JunctionType = boost::junctions::detail::n_m_junction<2u, 3u, std::set<std::string, std::less<std::string>, std::allocator<std::string> > >]
Sincerly Florian