
I want to implement this:
// returns whether Seq1 includes each of the elements in Seq2
// using Pred to determine type equality
template
{};
The line I don't know how to write is flagged, but the functionality I
want to express is shown.
In case it's relevant, here is the rest of my code:
// metafunction class for TR1-conforming is_base_of
struct is_base_of {
template
{}; Thanks for all help, Scott

Scott Meyers wrote:
OK.
Wouldn't it be nicer if 'is_base_of<_1,_2>' would just work for the predicate? I'll add it to our requirements.
This is a nice starting point. Let's simplify away the mpl::apply and
just pass on the predicate. Let's also be 'using namespace boost::mpl'
here for readability.
template

It will take me a few days to digest your comments (this is largely new territory for me), but I wanted to acknowledge your help now. Thanks very much.
Yes, I ran into this problem playing around as a result of the help posted earlier. As I said, it will take me a while to get a grasp on what you've done. I have to look a lot of stuff up and write a lot of test cases :-) Scott

Scott Meyers wrote:
It will take me a few days to digest your comments
Hopefully not because they're confusing :-). I tried to increase conciseness with my second post.
Thanks too -- a reader who's new to the territory is most valuable to improve one's communication skills.
There's a slightly altered approach to this problem attached to this
message for some additional fun.
Regards,
Tobias
#include

Tobias, I looked in your code and have an additional question. Compiletime complexity of the algorithm is exponential as I see it. Isn't it probably better to convert the first vector into a set and make set lookups with amortized constant time? Regards, Ovanes -----Original Message----- From: Tobias Schwinger [mailto:tschwinger@isonews2.com] Sent: Sonntag, 18. März 2007 14:55 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [mpl] Implementing includes_if Scott Meyers wrote:
It will take me a few days to digest your comments
Hopefully not because they're confusing :-). I tried to increase conciseness with my second post.
Thanks too -- a reader who's new to the territory is most valuable to improve one's communication skills.
There's a slightly altered approach to this problem attached to this message for some additional fun. Regards, Tobias

Hi Ovanes, Ovanes Markarian wrote:
Not quite - it's just quadratic in the worst case (I believe it's just about the wording: Although there's a constant exponent in O(N^2), "exponential complexity" is something with N being a factor of the exponent e.g. O(2^N)).
Seems it's only possible to implement the "Pred = is_same<_1,_2> case", this way - not the "Pred = is_base_of<_1,_2> case" asked for by the OP. That issue aside, it seems an interesting idea. If you decide to give it a try I'd be interested to see your benchmarks! Regards, Tobias

on Sat Mar 17 2007, Tobias Schwinger
There is an inherent limitation in that regard. These kinds of problems come up repeatedly, so Aleksey and I agree the library should provide a solution. We had a long discussion on the boost-devel list where we talked about the same issues in terms of runtime lambda expressions: http://lists.boost.org/Archives/boost/2005/01/78409.php As I said, this thread is long (it contains a whole thread attached to one message in the outer thread -- how appropriate!) but it's worth a read. Incidentally, protect<> doesn't help as it does something different. -- Dave Abrahams Boost Consulting www.boost-consulting.com

David Abrahams wrote:
Oh, thanks!
Incidentally, I provided something very similar to 'outer' (discussed in
that thread) in the follow-up, called 'defer' (inspired by Chaos).
It's so easy, that it's almost provocative:
// returns an unspecified placeholder expression whose evaluation
// results in the original argument, no placeholder substitution
// applied
template<typename PlaceholderExpr>
struct defer
{
template<typename IgnoredPlaceholder> struct get
{
typedef PlaceholderExpr type;
};
typedef typename defer<PlaceholderExpr>::template get<_> type;
};
BOOST_MPL_ASSERT((
is_same
Yes, namely nested binds - I figured that out, by now :-). Regards, Tobias
participants (4)
-
David Abrahams
-
Ovanes Markarian
-
Scott Meyers
-
Tobias Schwinger