Re: [boost] Re: MPL::lambda on MSVC

2003-03-30 Thread David Abrahams
"Jaap Suter" <[EMAIL PROTECTED]> writes:

>> The error occurs on the line with the boost static constant.
>
> Never mind that, I changed the code after I wrote the message.
>
> Here's the code in hopefully better formatting.

Looks to me like this code has the exact same problem.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

___
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Re: [boost] Re: MPL Lambda on MSVC 7

2003-01-12 Thread David Abrahams
"Jaap Suter" <[EMAIL PROTECTED]> writes:

>> > Hi,
>>
>> Hi Jaap,
>
> Wow, fast reply. Thanks!
>
>> including MSVC 6.5/7.0 (assuming the latest CVS sources). Or are you using
>> the 1.29.0 archive?
>
> I have the latest CVS sources (I did a full 'get' over the 1_29_0 release in
> case you wonder where the boost_1_29_0 directory comes from in the path
> below).
>
>> > but that didn't fix it.
>>
>> Hmm, works for me, even if I remove the 'plus' inheritance:
>
> You are right, I apologize. I never actually tried the example in the
> original post, I just assumed that it was the same as the actual code.
> However, after your reply I tried it, and it does in fact compile. So I
> tried to come up with the actual smallest example that doesn't compile, even
> with the LAMBDA_SUPPORT macro. It looks as follows:
>
> template< class T >
> struct meta_fun_1
> {
> typedef mpl::integral_c< typename T::value_type, 0 > type;
> BOOST_MPL_AUX_LAMBDA_SUPPORT( 1, meta_fun_1, (T) )
> };
>
> template< class List, class T >
> struct meta_fun_2
> {
> typedef typename mpl::fold< List,
> mpl::integral_c< size_t, 0 >,
> meta_fun_1< mpl::_1 >
> >::type type;
> };

Provided I add the neccessary prelude (below), that compiles fine for
me on vc7.  Don't you need to instantiate these to see the error?

# include 
# include 
# include 
# include 

namespace mpl = boost::mpl;
using std::size_t;

--

Hmm, OK, here's a minimal case:

# include 
# include 
# include 
# include 
# include 
# include 

namespace mpl = boost::mpl;
using std::size_t;

template< class T, class U >
struct meta_fun_1
: mpl::integral_c< typename T::value_type, 0 >
{
BOOST_MPL_AUX_LAMBDA_SUPPORT( 2, meta_fun_1, (T,U) )
};

typedef mpl::fold< mpl::list_c,
mpl::integral_c< size_t, 0 >,
meta_fun_1< mpl::_1, mpl::_2 >
>::type too;

I see the problem :(
Incidentally, your example is trying to pass a unary metafunction to
fold; it should be binary.  But that has nothing to do with it :(

-- 
   David Abrahams
   [EMAIL PROTECTED] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

___
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost



RE: [boost] Re: MPL Lambda on MSVC 7

2003-01-12 Thread Aleksey Gurtovoy
Jaap Suter wrote:
> So I tried to come up with the actual smallest example that 
> doesn't compile, even
> with the LAMBDA_SUPPORT macro. It looks as follows:
> 
> template< class T >
> struct meta_fun_1
> {
> typedef mpl::integral_c< typename T::value_type, 0 > type;
> BOOST_MPL_AUX_LAMBDA_SUPPORT( 1, meta_fun_1, (T) )
> };
> 
> template< class List, class T >
> struct meta_fun_2
> {
> typedef typename mpl::fold< List,
> mpl::integral_c< size_t, 0 >,
> meta_fun_1< mpl::_1 >
> >::type type;
> };
> 
> The problem lies in the fact that I try to use a dependent type in
> meta_fun_1. 

Yep, to be concrete, 'T::value_type'. Please see the following posts for an
explanation of the shortcoming, as well as for a technique to work around
it:

http://lists.boost.org/MailArchives/boost/msg39915.php (the relevant part
starts from "Well, having said that..." paragraph)
http://lists.boost.org/MailArchives/boost/msg39930.php (further explanation)


> I have pasted the full compiler error at the bottom of the
> message (it's rather long). The first few lines say:
> 
> 'value_type' : is not a member of 'boost::mpl::arg'
> with
> [
> N=1
> ]
> 
> e:\library\boost_1_29_0\boost\type_traits\is_convertible.hpp(61) : see
> reference to class template instantiation 'test::meta_fun_1' being
> compiled
> with
> [
> T=boost::mpl::_1
> ]
> 
> Any suggestions? I can work-around it by using plain integers 
> instead of ::value_type, but it's not as elegant.

template< class T >
struct meta_fun_1_impl
{
typedef mpl::integral_c< typename T::value_type, 0 > type;
};

template< class T >
struct meta_fun_1
: mpl::if_<
  mpl::is_placeholder
, mpl::identity
, meta_fun_1_impl
>::type
{
BOOST_MPL_AUX_LAMBDA_SUPPORT( 1, meta_fun_1, (T) )
};

Or, if it's an internal/helper metafunction, just re-write it as a
metafunction class and, if you need to bind parameters to it - well, just
use 'bind':

typedef fold< types, int_c<0>, bind
>::type res;

A.
___
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost



RE: [boost] Re: [MPL Lambda]

2002-11-22 Thread Aleksey Gurtovoy
David B. Held wrote:
> > For your own metafunctions, you have to intrude them a 
> > little bit, but otherwise it works as well:
> >
> > template< typename T > struct f
> > {
> > typedef T type;
> > BOOST_MPL_AUX_LAMBDA_SUPPORT(1,f,(T)) // here
> > };
> > [...]
> 
> I assume it's safe to have this stuff in even for compilers 
> that don't need it? 

Yes.

> If I recall, it gets evaluated to nothing on conforming platforms? 

Yes.

> Also, I assume the first argument is the arity, and the last argument
> is a parenthesized list of the template parameters?

Exactly!

Aleksey
___
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost



Re: [boost] Re: MPL lambda

2002-11-15 Thread Dirk Gerrits
Mat Marcus wrote:


Scatter hierarchies can be achieved by using inherit_linearly together
with mpl::inherit. See the second example that Aleksey cited *is* an
example of a scatter hierarchy.


Forgive me, I hadn't realized this. That's just too cool! :) Thanks.

Regards,
Dirk Gerrits

___
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost



Re: [boost] Re: MPL lambda

2002-11-15 Thread Mat Marcus
Scatter hierarchies can be achieved by using inherit_linearly 
together with mpl::inherit. See the second example that Aleksey 
cited *is* an example of a scatter hierarchy.




--On Friday, November 15, 2002 5:28 PM +0100 Dirk Gerrits 
<[EMAIL PROTECTED]> wrote:

Aleksey Gurtovoy wrote:


Rozental, Gennadiy wrote:

> Also is there gen_scattered/linear_hierarchy implementation
> somewhere for MPL sequenses?


MPL's 'inherit_linearly' algorithm + 'inherit' metafunction
(in the  CVS now)
cover both of these. Please see
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/bo
ost/boost/libs/m pl/example/inherit_linearly.cpp and
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/bo
ost/boost/libs/m pl/example/inherit_multiply.cpp for the
corresponding examples.


This is some very cool stuff!

However, the way I understand it, inherit_linearly takes a
type sequence (like mpl::list) as an argument and inherit
takes the types themselves as arguments. I'd like to have an
inherit that takes a type sequence as an argument, instead of
or in addition to the current inherit. This is because I need
to do some Modern-C++-Design-ish stuff which needs a
scattered hierarchy instead of a linear one.

Regards,
Dirk Gerrits



___
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost



___
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost