[fusion] variadic mpl for use with fusion

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[fusion] variadic mpl for use with fusion

Fletcher, John P
Larry

I have now taken this on to the next stage as follows:

1. I have built gcc 4.4 (20090109) and confirmed that this clears the bug I reported last time.

2. I have then attempted to use the variadic mpl with boost fusion.  This fails for a reason to do with mpl as follows.

boost/mpl/iter_fold_if.hpp and various other locations in mpl need apply1 which is not defined by your apply.hpp and is by both 1.35.0 and 1.37.0 versions.

Therefore anything which includes your mpl fails on that file, which is needed by fusion.

The solution should be to go through the rest of mpl and replace apply1 with apply, or else define it in your apply.h.

I think your file should define apply1, apply2 etc for backward compatibility as it is in the manual.  What do you think?

John

P.S. Note change in topic name

________________________________________
From: Larry Evans [[hidden email]]
Sent: 27 January 2009 01:37
To: [hidden email]
Subject: Re: [Spirit-devel] [fusion] Sequence IO query

[snip]
>
> I have not reported this to gnu.  I have not had a chance to run this with gcc 4.4

I also got the pt.c:15558 error.  However, with gcc-4.4 download
mentioned in previous post, it compiles without error.

>
> Please let me know what you think, or ask for more information.

I think it's great that you got as much to compile as you did.
I hope mpl hasn't changed too much so that the variadic version
doesn't have to change too much.  IIRC, the most tedious part of
converting mpl to the variadic version was finding all the preprocessor
calls which produced the templates (e.g. vector1, ... vector5,...)
and replacing those with variadic counterparts.  Also, that wasn't
totally completed.  I can't remember what still needs to be done.  I've
probably got it written down somewhere, but I'll have to look :(

[snip]


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

FW: [fusion] variadic mpl for use with fusion

Fletcher, John P
Larry

I have now solved this with the following additions to your apply.h

template < class F, typename A1 >
struct apply1 : apply < F, A1 > { };

template < class F, typename A1, typename A2>
struct apply2 : apply < F, A1, A2 > { } ;

That solves the problem in iter_fold_if.hpp which is used in mpl/find.hpp

John
________________________________________
From: Fletcher, John P [[hidden email]]
Sent: 31 January 2009 23:04
To: Spirit Development
Subject: [Spirit-devel]  [fusion] variadic mpl for use with fusion

Larry

I have now taken this on to the next stage as follows:

1. I have built gcc 4.4 (20090109) and confirmed that this clears the bug I reported last time.

2. I have then attempted to use the variadic mpl with boost fusion.  This fails for a reason to do with mpl as follows.

boost/mpl/iter_fold_if.hpp and various other locations in mpl need apply1 which is not defined by your apply.hpp and is by both 1.35.0 and 1.37.0 versions.

Therefore anything which includes your mpl fails on that file, which is needed by fusion.

The solution should be to go through the rest of mpl and replace apply1 with apply, or else define it in your apply.h.

I think your file should define apply1, apply2 etc for backward compatibility as it is in the manual.  What do you think?

John

P.S. Note change in topic name

________________________________________
From: Larry Evans [[hidden email]]
Sent: 27 January 2009 01:37
To: [hidden email]
Subject: Re: [Spirit-devel] [fusion] Sequence IO query

[snip]
>
> I have not reported this to gnu.  I have not had a chance to run this with gcc 4.4

I also got the pt.c:15558 error.  However, with gcc-4.4 download
mentioned in previous post, it compiles without error.

>
> Please let me know what you think, or ask for more information.

I think it's great that you got as much to compile as you did.
I hope mpl hasn't changed too much so that the variadic version
doesn't have to change too much.  IIRC, the most tedious part of
converting mpl to the variadic version was finding all the preprocessor
calls which produced the templates (e.g. vector1, ... vector5,...)
and replacing those with variadic counterparts.  Also, that wasn't
totally completed.  I can't remember what still needs to be done.  I've
probably got it written down somewhere, but I'll have to look :(

[snip]


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

FW: FW: [fusion] variadic mpl for use with fusion

Fletcher, John P
Putting in them all in from apply0 to apply5 has enabled me to use variadic mpl with boost fusion vector.

John
________________________________________
From: Fletcher, John P [[hidden email]]
Sent: 31 January 2009 23:22
To: Spirit Development
Subject: [Spirit-devel] FW:   [fusion] variadic mpl for use with fusion

Larry

I have now solved this with the following additions to your apply.h

template < class F, typename A1 >
struct apply1 : apply < F, A1 > { };

template < class F, typename A1, typename A2>
struct apply2 : apply < F, A1, A2 > { } ;

That solves the problem in iter_fold_if.hpp which is used in mpl/find.hpp

John
________________________________________
From: Fletcher, John P [[hidden email]]
Sent: 31 January 2009 23:04
To: Spirit Development
Subject: [Spirit-devel]  [fusion] variadic mpl for use with fusion

Larry

I have now taken this on to the next stage as follows:

1. I have built gcc 4.4 (20090109) and confirmed that this clears the bug I reported last time.

2. I have then attempted to use the variadic mpl with boost fusion.  This fails for a reason to do with mpl as follows.

boost/mpl/iter_fold_if.hpp and various other locations in mpl need apply1 which is not defined by your apply.hpp and is by both 1.35.0 and 1.37.0 versions.

Therefore anything which includes your mpl fails on that file, which is needed by fusion.

The solution should be to go through the rest of mpl and replace apply1 with apply, or else define it in your apply.h.

I think your file should define apply1, apply2 etc for backward compatibility as it is in the manual.  What do you think?

John

P.S. Note change in topic name

________________________________________
From: Larry Evans [[hidden email]]
Sent: 27 January 2009 01:37
To: [hidden email]
Subject: Re: [Spirit-devel] [fusion] Sequence IO query

[snip]
>
> I have not reported this to gnu.  I have not had a chance to run this with gcc 4.4

I also got the pt.c:15558 error.  However, with gcc-4.4 download
mentioned in previous post, it compiles without error.

>
> Please let me know what you think, or ask for more information.

I think it's great that you got as much to compile as you did.
I hope mpl hasn't changed too much so that the variadic version
doesn't have to change too much.  IIRC, the most tedious part of
converting mpl to the variadic version was finding all the preprocessor
calls which produced the templates (e.g. vector1, ... vector5,...)
and replacing those with variadic counterparts.  Also, that wasn't
totally completed.  I can't remember what still needs to be done.  I've
probably got it written down somewhere, but I'll have to look :(

[snip]


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

cppljevans
On 01/31/09 17:42, Fletcher, John P wrote:
 > Putting in them all in from apply0 to apply5 has enabled me to use
 > variadic mpl with boost fusion vector.

[snip]>

 > John
 > ________________________________________
 > From: Fletcher, John P [[hidden email]]
 > Sent: 31 January 2009 23:22
 > To: Spirit Development
 > Subject: [Spirit-devel] FW:   [fusion] variadic mpl for use with fusion
 >
 > Larry
 >
 > I have now solved this with the following additions to your apply.h
 >
 > template < class F, typename A1 >
 > struct apply1 : apply < F, A1 > { };
 >
 > template < class F, typename A1, typename A2>
 > struct apply2 : apply < F, A1, A2 > { } ;
 >
 > That solves the problem in iter_fold_if.hpp which is used in mpl/find.hpp
 >
 > John
 > ________________________________________
 > From: Fletcher, John P [[hidden email]]
 > Sent: 31 January 2009 23:04
 > To: Spirit Development
 > Subject: [Spirit-devel]  [fusion] variadic mpl for use with fusion
 >
 > Larry
 >
 > I have now taken this on to the next stage as follows:
 >
 > 1. I have built gcc 4.4 (20090109) and confirmed that this clears
 >    the bug I reported last time.

 >
 > 2. I have then attempted to use the variadic mpl with boost fusion.
 >    This fails for a reason to do with mpl as follows.
 >
 >
 >       boost/mpl/iter_fold_if.hpp and various other locations in mpl
 >       need apply1 which is not defined by your apply.hpp and is by
 >       both 1.35.0 and 1.37.0 versions.
 >
 >
 >    Therefore anything which includes your mpl fails on that file,
 >    which is needed by fusion. The solution should be to go through
 >    the rest of mpl and replace apply1 with apply, or else define it
 >    in your apply.h. I think your file should define apply1, apply2
 >    etc for backward compatibility as it is in the manual.
 >
 >    What do you think?

I don't know how to answer without knowing what location in what
manual. My initial reaction is that apply1, apply2, ..., applyN should
be deprecated and replaced with the variadic apply and that any
classes and templates which depend on them should be adapated to use
the variadic apply.  For example, you mention in your 01/31/09 17:42
post:

 > Putting in them all in from apply0 to apply5 has enabled me to use
 > variadic mpl with boost fusion vector.

Is there some reason that iter_fold_if and fusion vector could not be
changed to use the variadic apply?

Maybe I should upload the variadic mpl to boost sandbox svn so that we
can track the changes and their rationale.

What do you think?

 >
 > John
 >
 > P.S. Note change in topic name

I think the convention for changing the topic name is to type the new
topic in the Subject line suffixed by '(was " and the old topic name.
I guess subsequent posts can then delete the suffix.  That way,
someone searching for the old topic in the Subject will find it.

BTW, I've had to edit you posts in emacs to get the lines to wrap
around column 70.  Is there some way you could post so that your lines
wrap around that column?

[snip]

Larry


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

cppljevans
On 02/01/09 09:01, Larry Evans wrote:
 > On 01/31/09 17:42, Fletcher, John P wrote:
 >  > Putting in them all in from apply0 to apply5 has enabled me to use
 >  > variadic mpl with boost fusion vector.
 >
 > [snip]>
 >
 >  > John
 >  > ________________________________________
 >  > From: Fletcher, John P [[hidden email]]
 >  > Sent: 31 January 2009 23:22
 >  > To: Spirit Development
 >  > Subject: [Spirit-devel] FW:   [fusion] variadic mpl for use with
fusion
 >  >
 >  > Larry
 >  >
 >  > I have now solved this with the following additions to your apply.h
 >  >
 >  > template < class F, typename A1 >
 >  > struct apply1 : apply < F, A1 > { };
 >  >
 >  > template < class F, typename A1, typename A2>
 >  > struct apply2 : apply < F, A1, A2 > { } ;
 >  >
 >  > That solves the problem in iter_fold_if.hpp which is used in
mpl/find.hpp

The iter_fold_if.hpp problem is actually mentioned in the file:

    c++committee/VariadicTemplatesExperiences.txt

of the vault's mpl-vt.zip.  That file also contains some rationale for
design of the tupmap_indexed template mentioned in my other post:

   http://tinyurl.com/aqock8

That .txt file also mentioned a flat version instead of inherited
version of tuple (flat to minimize space); however, it also mentioned
a problem with alignment calculation.  That alignment calculation
problem has been solved in the aligned_types.2.zip in the vault;
however, one reason I didn't pursue it further was the alignment
calculation used more template instantiations and I was afraid that
wouldn't be acceptable :( .  Does your variadic version of tuple
suffer the same space problem (i.e. the one mentioned in the aqock8
post)?


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

Fletcher, John P
In reply to this post by cppljevans
Larry

Sorry, I was not very clear.
I meant the manual pages for boost MPL, and in particular the page for apply, which actually gives parallel examples for apply and apply1.
The applyN could be deprecated, but getting rid of them in MPL itself will not be enough as they could be in code which makes use of MPL,
either in other parts of Boost or in code outside Boost altogether.
The main advantage of a variadic MPL is so that other code which uses it, such as variadic fusion, is freed from having size limits.
I have managed that in most of the things I have done in the implementation of the variaidic tuple.

What I did yesterday was to modify your apply.hpp so that the rest of MPL works unchanged with it.
One reason I did it that way was that I was able to run it with different versions of boost MPL, from 1.35.0 and 1.37.0 and both worked O.K.
To start working on iter_fold_if.hpp I would have to choose one or the other version and it would not have worked on both.
In that case the change needed is to replace occurences of apply1 by apply.

The occurrences of apply0 to apply5 are deep in something in mpl/aux_/precompiled/gcc.

Regarding deployment, is there a stage where variadic is going to be a mainstream option in boost?
At one time I read the boost development list, but I don't think I have time at the moment.
At that point the variadic code could go in, subject of course to the compilers to test it.  I am not an expert on MPL.
I was coming to this as someone interested in run time variadic code, which I have been experimenting with, using only variants of gcc.

John

P.S. I am sorry you are having trouble with these postings.
They are based on Microsoft Outlook, my work email system, accessed via the web using Firefox plus IE Tab,
so that I get the richer Internet Explorer interface.  They wrap automatically as I type them.  Do they not wrap for you at all?
I have gone through this and put in forced line breaks at suitable points.


________________________________________
From: Larry Evans [[hidden email]]
Sent: 01 February 2009 15:01
To: [hidden email]
Subject: Re: [Spirit-devel] FW: FW: [fusion] variadic mpl for use with fusion

On 01/31/09 17:42, Fletcher, John P wrote:
 > Putting in them all in from apply0 to apply5 has enabled me to use
 > variadic mpl with boost fusion vector.

[snip]>

 > John
 > ________________________________________
 > From: Fletcher, John P [[hidden email]]
 > Sent: 31 January 2009 23:22
 > To: Spirit Development
 > Subject: [Spirit-devel] FW:   [fusion] variadic mpl for use with fusion
 >
 > Larry
 >
 > I have now solved this with the following additions to your apply.h
 >
 > template < class F, typename A1 >
 > struct apply1 : apply < F, A1 > { };
 >
 > template < class F, typename A1, typename A2>
 > struct apply2 : apply < F, A1, A2 > { } ;
 >
 > That solves the problem in iter_fold_if.hpp which is used in mpl/find.hpp
 >
 > John
 > ________________________________________
 > From: Fletcher, John P [[hidden email]]
 > Sent: 31 January 2009 23:04
 > To: Spirit Development
 > Subject: [Spirit-devel]  [fusion] variadic mpl for use with fusion
 >
 > Larry
 >
 > I have now taken this on to the next stage as follows:
 >
 > 1. I have built gcc 4.4 (20090109) and confirmed that this clears
 >    the bug I reported last time.

 >
 > 2. I have then attempted to use the variadic mpl with boost fusion.
 >    This fails for a reason to do with mpl as follows.
 >
 >
 >       boost/mpl/iter_fold_if.hpp and various other locations in mpl
 >       need apply1 which is not defined by your apply.hpp and is by
 >       both 1.35.0 and 1.37.0 versions.
 >
 >
 >    Therefore anything which includes your mpl fails on that file,
 >    which is needed by fusion. The solution should be to go through
 >    the rest of mpl and replace apply1 with apply, or else define it
 >    in your apply.h. I think your file should define apply1, apply2
 >    etc for backward compatibility as it is in the manual.
 >
 >    What do you think?

I don't know how to answer without knowing what location in what
manual. My initial reaction is that apply1, apply2, ..., applyN should
be deprecated and replaced with the variadic apply and that any
classes and templates which depend on them should be adapated to use
the variadic apply.  For example, you mention in your 01/31/09 17:42
post:

 > Putting in them all in from apply0 to apply5 has enabled me to use
 > variadic mpl with boost fusion vector.

Is there some reason that iter_fold_if and fusion vector could not be
changed to use the variadic apply?

Maybe I should upload the variadic mpl to boost sandbox svn so that we
can track the changes and their rationale.

What do you think?

 >
 > John
 >
 > P.S. Note change in topic name

I think the convention for changing the topic name is to type the new
topic in the Subject line suffixed by '(was " and the old topic name.
I guess subsequent posts can then delete the suffix.  That way,
someone searching for the old topic in the Subject will find it.

BTW, I've had to edit you posts in emacs to get the lines to wrap
around column 70.  Is there some way you could post so that your lines
wrap around that column?

[snip]

Larry


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

Fletcher, John P
In reply to this post by cppljevans
Larry

Thanks for the links.  I was concentrating on the errors which were preventing me from compling boost fusion.

I downloaded the aligned_types file when I was downloading variadic mpl, but have not looked at it yet.

My variadic tuple is in many ways a wrapper for the TR1 tuple, so I have the same internals as the coder of the TR1library headers.
As TR1 defines the standard, that will be a matter for the implementer and will differ for different compilers.
The main use of MPL I have made is in some macros to decode the locations of the requests,
and also to check validity and give sensible compiler errors for things which are outside the range.

I haven't done anything to look at how efficient are the solutions.

John

________________________________________
From: Larry Evans [[hidden email]]
Sent: 01 February 2009 16:59
To: [hidden email]
Subject: Re: [Spirit-devel] FW: FW: [fusion] variadic mpl for use with fusion

On 02/01/09 09:01, Larry Evans wrote:
 > On 01/31/09 17:42, Fletcher, John P wrote:
 >  > Putting in them all in from apply0 to apply5 has enabled me to use
 >  > variadic mpl with boost fusion vector.
 >
 > [snip]>
 >
 >  > John
 >  > ________________________________________
 >  > From: Fletcher, John P [[hidden email]]
 >  > Sent: 31 January 2009 23:22
 >  > To: Spirit Development
 >  > Subject: [Spirit-devel] FW:   [fusion] variadic mpl for use with
fusion
 >  >
 >  > Larry
 >  >
 >  > I have now solved this with the following additions to your apply.h
 >  >
 >  > template < class F, typename A1 >
 >  > struct apply1 : apply < F, A1 > { };
 >  >
 >  > template < class F, typename A1, typename A2>
 >  > struct apply2 : apply < F, A1, A2 > { } ;
 >  >
 >  > That solves the problem in iter_fold_if.hpp which is used in
mpl/find.hpp

The iter_fold_if.hpp problem is actually mentioned in the file:

    c++committee/VariadicTemplatesExperiences.txt

of the vault's mpl-vt.zip.  That file also contains some rationale for
design of the tupmap_indexed template mentioned in my other post:

   http://tinyurl.com/aqock8

That .txt file also mentioned a flat version instead of inherited
version of tuple (flat to minimize space); however, it also mentioned
a problem with alignment calculation.  That alignment calculation
problem has been solved in the aligned_types.2.zip in the vault;
however, one reason I didn't pursue it further was the alignment
calculation used more template instantiations and I was afraid that
wouldn't be acceptable :( .  Does your variadic version of tuple
suffer the same space problem (i.e. the one mentioned in the aqock8
post)?


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

Fletcher, John P
In reply to this post by cppljevans
Larry

The next problem.

This page in the mpl reference:

 http://www.boost.org/doc/libs/1_37_0/libs/mpl/doc/refmanual/find.html

gives this example:

typedef vector<char,int,unsigned,long,unsigned long> types;
typedef find<types,unsigned>::type iter;

BOOST_MPL_ASSERT(( is_same< deref<iter>::type, unsigned > ));
BOOST_MPL_ASSERT_RELATION( iter::pos::value, ==, 2 );

This is the only place where I could find the pos thing as a way to get back to the location of the key in the vector.
I use it to detect if the key is in range in my variadic tuple.

This example fails with your variadic mpl saying that pos is not defined.
I am at present digging into mpl to find out where it defines it.
When I find that I will know what to do about it.

Cheers

John
________________________________________
From: Larry Evans [[hidden email]]
Sent: 01 February 2009 16:59
To: [hidden email]
Subject: Re: [Spirit-devel] FW: FW: [fusion] variadic mpl for use with fusion

On 02/01/09 09:01, Larry Evans wrote:
 > On 01/31/09 17:42, Fletcher, John P wrote:
 >  > Putting in them all in from apply0 to apply5 has enabled me to use
 >  > variadic mpl with boost fusion vector.
 >
 > [snip]>
 >
 >  > John
 >  > ________________________________________
 >  > From: Fletcher, John P [[hidden email]]
 >  > Sent: 31 January 2009 23:22
 >  > To: Spirit Development
 >  > Subject: [Spirit-devel] FW:   [fusion] variadic mpl for use with
fusion
 >  >
 >  > Larry
 >  >
 >  > I have now solved this with the following additions to your apply.h
 >  >
 >  > template < class F, typename A1 >
 >  > struct apply1 : apply < F, A1 > { };
 >  >
 >  > template < class F, typename A1, typename A2>
 >  > struct apply2 : apply < F, A1, A2 > { } ;
 >  >
 >  > That solves the problem in iter_fold_if.hpp which is used in
mpl/find.hpp

The iter_fold_if.hpp problem is actually mentioned in the file:

    c++committee/VariadicTemplatesExperiences.txt

of the vault's mpl-vt.zip.  That file also contains some rationale for
design of the tupmap_indexed template mentioned in my other post:

   http://tinyurl.com/aqock8

That .txt file also mentioned a flat version instead of inherited
version of tuple (flat to minimize space); however, it also mentioned
a problem with alignment calculation.  That alignment calculation
problem has been solved in the aligned_types.2.zip in the vault;
however, one reason I didn't pursue it further was the alignment
calculation used more template instantiations and I was afraid that
wouldn't be acceptable :( .  Does your variadic version of tuple
suffer the same space problem (i.e. the one mentioned in the aqock8
post)?


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

cppljevans
In reply to this post by Fletcher, John P
On 02/01/09 11:09, Fletcher, John P wrote:
 > Larry
 >
 > Sorry, I was not very clear.
 > I meant the manual pages for boost MPL, and in particular the page
 > for apply, which actually gives parallel examples for apply and
 > apply1.  The applyN could be deprecated, but getting rid of them in
 > MPL itself will not be enough as they could be in code which makes
 > use of MPL, either in other parts of Boost or in code outside Boost
 > altogether.  The main advantage of a variadic MPL is so that other
 > code which uses it, such as variadic fusion, is freed from having
 > size limits.  I have managed that in most of the things I have done
 > in the implementation of the variaidic tuple.

AFAICT, the only reason other parts of boost would use apply1 or
apply2, etc. is for compile-time efficiency and to make the code more
self-documenting.  I would think that replacing all these with just
apply would work; so, maybe just a gcc pragma saying they're
deprecated would be best.  IOW, something like:

template<typename ...T>
struct template_X
{};

#define DEPRECATE_TEMPLATE_XN_TEMPLATES
#ifdef DEPRECATE_TEMPLATE_XN_TEMPLATES
#pragma message "template_XN<T1,T2,...,TN> deprecated. Use
template_X<T1,T2,...,TN>."
#endif

template<class T1>
struct template_X1 : public template_X<T1>
{};


 >
 > What I did yesterday was to modify your apply.hpp so that the rest
 > of MPL works unchanged with it.  One reason I did it that way was
 > that I was able to run it with different versions of boost MPL, from
 > 1.35.0 and 1.37.0 and both worked O.K.  To start working on
 > iter_fold_if.hpp I would have to choose one or the other version and
 > it would not have worked on both.  In that case the change needed is
 > to replace occurences of apply1 by apply.

I don't follow.  Is iter_fold_if.hpp different between 1.35.0 and
1.37.0?

 >
 > The occurrences of apply0 to apply5 are deep in something in
 > mpl/aux_/precompiled/gcc.

I know.  I've already converted some of those to use variadic
templates.  It was very tedious ;(.  I just didn't get around to doing
all of them.

 >
 > Regarding deployment, is there a stage where variadic is going to be
 > a mainstream option in boost?

I don't know.

[snip]
 >
 > John
 >
 > P.S. I am sorry you are having trouble with these postings.  They
 > are based on Microsoft Outlook, my work email system, accessed via
 > the web using Firefox plus IE Tab, so that I get the richer Internet
 > Explorer interface.  They wrap automatically as I type them.  Do
 > they not wrap for you at all?  I have gone through this and put in
 > forced line breaks at suitable points.

When I viewed the above post in my thunderbird reader, the lines
looked like they wrapped around column 140.  For example, the
following line wrapped at column 140:

 > I meant the manual pages for boost MPL, and in particular the page
for apply, which actually gives parallel examples for apply and apply1.

although when I post it now, it wraps at 72 (which is what I have my
thunderbird wrap column set to).


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

Fletcher, John P
Larry

I need to thank you for your patience.
I see that quite a lot of what I have been writing about is all covered in your document of your experiences.
I did read it when I first opened your files, but did not appreciate the significance of some of it until now.

I realise now that the find operation is something which you have not yet covered, so it is hardly surprising it does not work.

It is important for me as within the variadic tuple I am keen to provide good compiler error messages when the user does something wrong.
I have done that within the internals using find to get back to the numeric location in the type bundle.

I have had a look at the implementation of tr1::tuple and the specification of boost::tuple and neither of those provide an equivalent.

This means that the only way ahead is to find some way of getting the information and using that to build a variadic version of mpl::find.

Have you thought about this, or discussed it with Doug Gregor?

Thanks for your work

John

________________________________________
From: Larry Evans [[hidden email]]
Sent: 02 February 2009 13:17
To: [hidden email]
Subject: Re: [Spirit-devel] FW: FW: [fusion] variadic mpl for use with fusion

On 02/01/09 11:09, Fletcher, John P wrote:
 > Larry
 >
 > Sorry, I was not very clear.
 > I meant the manual pages for boost MPL, and in particular the page
 > for apply, which actually gives parallel examples for apply and
 > apply1.  The applyN could be deprecated, but getting rid of them in
 > MPL itself will not be enough as they could be in code which makes
 > use of MPL, either in other parts of Boost or in code outside Boost
 > altogether.  The main advantage of a variadic MPL is so that other
 > code which uses it, such as variadic fusion, is freed from having
 > size limits.  I have managed that in most of the things I have done
 > in the implementation of the variaidic tuple.

AFAICT, the only reason other parts of boost would use apply1 or
apply2, etc. is for compile-time efficiency and to make the code more
self-documenting.  I would think that replacing all these with just
apply would work; so, maybe just a gcc pragma saying they're
deprecated would be best.  IOW, something like:

template<typename ...T>
struct template_X
{};

#define DEPRECATE_TEMPLATE_XN_TEMPLATES
#ifdef DEPRECATE_TEMPLATE_XN_TEMPLATES
#pragma message "template_XN<T1,T2,...,TN> deprecated. Use
template_X<T1,T2,...,TN>."
#endif

template<class T1>
struct template_X1 : public template_X<T1>
{};


 >
 > What I did yesterday was to modify your apply.hpp so that the rest
 > of MPL works unchanged with it.  One reason I did it that way was
 > that I was able to run it with different versions of boost MPL, from
 > 1.35.0 and 1.37.0 and both worked O.K.  To start working on
 > iter_fold_if.hpp I would have to choose one or the other version and
 > it would not have worked on both.  In that case the change needed is
 > to replace occurences of apply1 by apply.

I don't follow.  Is iter_fold_if.hpp different between 1.35.0 and
1.37.0?

 >
 > The occurrences of apply0 to apply5 are deep in something in
 > mpl/aux_/precompiled/gcc.

I know.  I've already converted some of those to use variadic
templates.  It was very tedious ;(.  I just didn't get around to doing
all of them.

 >
 > Regarding deployment, is there a stage where variadic is going to be
 > a mainstream option in boost?

I don't know.

[snip]
 >
 > John
 >
 > P.S. I am sorry you are having trouble with these postings.  They
 > are based on Microsoft Outlook, my work email system, accessed via
 > the web using Firefox plus IE Tab, so that I get the richer Internet
 > Explorer interface.  They wrap automatically as I type them.  Do
 > they not wrap for you at all?  I have gone through this and put in
 > forced line breaks at suitable points.

When I viewed the above post in my thunderbird reader, the lines
looked like they wrapped around column 140.  For example, the
following line wrapped at column 140:

 > I meant the manual pages for boost MPL, and in particular the page
for apply, which actually gives parallel examples for apply and apply1.

although when I post it now, it wraps at 72 (which is what I have my
thunderbird wrap column set to).


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

cppljevans
On 02/02/09 17:16, Fletcher, John P wrote:
> Larry
>
> I need to thank you for your patience.

Sure,  Your most welcome.

> I see that quite a lot of what I have been writing about is all covered in your document of your experiences.
> I did read it when I first opened your files, but did not appreciate the significance of some of it until now.
>
> I realise now that the find operation is something which you have not yet covered, so it is hardly surprising it does not work.
>
> It is important for me as within the variadic tuple I am keen to provide good compiler error messages when the user does something wrong.
> I have done that within the internals using find to get back to the numeric location in the type bundle.

Better error messages would've helped me a great deal during the
conversion of mpl to use variadic templates.  Good luck!

>
> I have had a look at the implementation of tr1::tuple and the specification of boost::tuple and neither of those provide an equivalent.
>
> This means that the only way ahead is to find some way of getting the information and using that to build a variadic version of mpl::find.
>
> Have you thought about this, or discussed it with Doug Gregor?

Nope.  However, I'm trying to solve the problem now.  I tried compiling
the mpl/test/find.cpp, but got very obscure error messages.  The
messages say something about and_ being incomplete, but that makes no
since because I just defined it as:

     template<class B0, class B1>
     struct and_binary
     : eval_if
       < B0
       , B1
       , false_
       >
     {
     };

     template<typename... B>
     struct and_
     : fold
       < package<B...>
       , true_
       , and_binary
         < arg<1>
         , arg<2>
         >
       >
     {
     };

Still working on it, but it's very hard to figure
out what's going wrong.  I've resorted to extracting
various subexpressions of the find expression to see
what is actually undefined.  It's going to take a while.
I'll let you know.

>
> Thanks for your work
>
Your welcome.

BTW, you mentioned in an earlier post that you'd done some FC++ work.
I've looked at haskell some and it appears monads could be used to
create a cross product.  AFAICT, a haskell list comprehension is like
a flattened cross product.  I mention that because I'd really be
interested in an mpl monad to see if it can be used to solve the
cross product problem mentioned in the MPL book.  One solution
is in the vault/Template Metaprogramming directory.
OTOH, I know you're busy, but still, I'd love to see alternative
solutions.  Who knows, since monads have also been used to
write parsers, it may come in handy for spirit also in the future.


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

Fletcher, John P
Larry

I am working on it from the other end, starting from your fold and modifying it.

I can't do copy and paste where I am at the moment.  I will send another message with some code in it in a minute.

FC++ is a long story, I'll give you a reference in a minute.

John

________________________________________
From: Larry Evans [[hidden email]]
Sent: 02 February 2009 23:53
To: [hidden email]
Subject: Re: [Spirit-devel] FW: FW: [fusion] variadic mpl for use with fusion

On 02/02/09 17:16, Fletcher, John P wrote:
> Larry
>
> I need to thank you for your patience.

Sure,  Your most welcome.

> I see that quite a lot of what I have been writing about is all covered in your document of your experiences.
> I did read it when I first opened your files, but did not appreciate the significance of some of it until now.
>
> I realise now that the find operation is something which you have not yet covered, so it is hardly surprising it does not work.
>
> It is important for me as within the variadic tuple I am keen to provide good compiler error messages when the user does something wrong.
> I have done that within the internals using find to get back to the numeric location in the type bundle.

Better error messages would've helped me a great deal during the
conversion of mpl to use variadic templates.  Good luck!

>
> I have had a look at the implementation of tr1::tuple and the specification of boost::tuple and neither of those provide an equivalent.
>
> This means that the only way ahead is to find some way of getting the information and using that to build a variadic version of mpl::find.
>
> Have you thought about this, or discussed it with Doug Gregor?

Nope.  However, I'm trying to solve the problem now.  I tried compiling
the mpl/test/find.cpp, but got very obscure error messages.  The
messages say something about and_ being incomplete, but that makes no
since because I just defined it as:

     template<class B0, class B1>
     struct and_binary
     : eval_if
       < B0
       , B1
       , false_
       >
     {
     };

     template<typename... B>
     struct and_
     : fold
       < package<B...>
       , true_
       , and_binary
         < arg<1>
         , arg<2>
         >
       >
     {
     };

Still working on it, but it's very hard to figure
out what's going wrong.  I've resorted to extracting
various subexpressions of the find expression to see
what is actually undefined.  It's going to take a while.
I'll let you know.

>
> Thanks for your work
>
Your welcome.

BTW, you mentioned in an earlier post that you'd done some FC++ work.
I've looked at haskell some and it appears monads could be used to
create a cross product.  AFAICT, a haskell list comprehension is like
a flattened cross product.  I mention that because I'd really be
interested in an mpl monad to see if it can be used to solve the
cross product problem mentioned in the MPL book.  One solution
is in the vault/Template Metaprogramming directory.
OTOH, I know you're busy, but still, I'd love to see alternative
solutions.  Who knows, since monads have also been used to
write parsers, it may come in handy for spirit also in the future.


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

Fletcher, John P
In reply to this post by cppljevans
Larry

This email software is a pain.  I can get a better email interface with IE Tab, but then cannot do copy and paste
to it from where I am working in Linux (VNC to another computer).  Hence two messages.
Log out and log in again to the web interface.

Here is my experimental code, which finds the first one.  I need to make it recurse and count how many times it has done it.
At the end I need to return and end type to signify that.

typedef mpl::vector<char,int,unsigned,long,unsigned long> types;

namespace experiment {

  // Following fold
  template <typename Sequence, typename Key>
  struct find;

  template <template < typename...> class Sequence,
            typename Head,
            typename... Tail,
            typename Key>
  struct find < Sequence <Head, Tail... > , Key >
    : boost::mpl::if_<is_same<Head,Key>,
                      mpl::int_<0>,
                      mpl::void_>::type
  {
  };

}

typedef experiment::find<types,char> what0;
typedef experiment::find<types,int> what1;
BOOST_MPL_ASSERT_RELATION( what0::value, ==, 0 );
BOOST_MPL_ASSERT(( is_same< what1::type, mpl::void_ > ));

I hope this helps.

John
________________________________________
From: Larry Evans [[hidden email]]
Sent: 02 February 2009 23:53
To: [hidden email]
Subject: Re: [Spirit-devel] FW: FW: [fusion] variadic mpl for use with fusion

On 02/02/09 17:16, Fletcher, John P wrote:
> Larry
>
> I need to thank you for your patience.

Sure,  Your most welcome.

> I see that quite a lot of what I have been writing about is all covered in your document of your experiences.
> I did read it when I first opened your files, but did not appreciate the significance of some of it until now.
>
> I realise now that the find operation is something which you have not yet covered, so it is hardly surprising it does not work.
>
> It is important for me as within the variadic tuple I am keen to provide good compiler error messages when the user does something wrong.
> I have done that within the internals using find to get back to the numeric location in the type bundle.

Better error messages would've helped me a great deal during the
conversion of mpl to use variadic templates.  Good luck!

>
> I have had a look at the implementation of tr1::tuple and the specification of boost::tuple and neither of those provide an equivalent.
>
> This means that the only way ahead is to find some way of getting the information and using that to build a variadic version of mpl::find.
>
> Have you thought about this, or discussed it with Doug Gregor?

Nope.  However, I'm trying to solve the problem now.  I tried compiling
the mpl/test/find.cpp, but got very obscure error messages.  The
messages say something about and_ being incomplete, but that makes no
since because I just defined it as:

     template<class B0, class B1>
     struct and_binary
     : eval_if
       < B0
       , B1
       , false_
       >
     {
     };

     template<typename... B>
     struct and_
     : fold
       < package<B...>
       , true_
       , and_binary
         < arg<1>
         , arg<2>
         >
       >
     {
     };

Still working on it, but it's very hard to figure
out what's going wrong.  I've resorted to extracting
various subexpressions of the find expression to see
what is actually undefined.  It's going to take a while.
I'll let you know.

>
> Thanks for your work
>
Your welcome.

BTW, you mentioned in an earlier post that you'd done some FC++ work.
I've looked at haskell some and it appears monads could be used to
create a cross product.  AFAICT, a haskell list comprehension is like
a flattened cross product.  I mention that because I'd really be
interested in an mpl monad to see if it can be used to solve the
cross product problem mentioned in the MPL book.  One solution
is in the vault/Template Metaprogramming directory.
OTOH, I know you're busy, but still, I'd love to see alternative
solutions.  Who knows, since monads have also been used to
write parsers, it may come in handy for spirit also in the future.


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

Fletcher, John P
In reply to this post by cppljevans
Larry

I forgot to give you a reference for FC++.

http://c2.com/cgi/wiki?FunctoidsInCpp will take you into a lot of discussion.

It does a lot more than Haskell - in fact that is only a small part of it.

I have done some unpublished and incomplete work on a variadic version of it which allows for things like

plusN(1, 2.5, 4, 5)

which will add them up and return the appropriate type.

Cheers

John
________________________________________
From: Larry Evans [[hidden email]]
Sent: 02 February 2009 23:53
To: [hidden email]
Subject: Re: [Spirit-devel] FW: FW: [fusion] variadic mpl for use with fusion

On 02/02/09 17:16, Fletcher, John P wrote:
> Larry
>
> I need to thank you for your patience.

Sure,  Your most welcome.

> I see that quite a lot of what I have been writing about is all covered in your document of your experiences.
> I did read it when I first opened your files, but did not appreciate the significance of some of it until now.
>
> I realise now that the find operation is something which you have not yet covered, so it is hardly surprising it does not work.
>
> It is important for me as within the variadic tuple I am keen to provide good compiler error messages when the user does something wrong.
> I have done that within the internals using find to get back to the numeric location in the type bundle.

Better error messages would've helped me a great deal during the
conversion of mpl to use variadic templates.  Good luck!

>
> I have had a look at the implementation of tr1::tuple and the specification of boost::tuple and neither of those provide an equivalent.
>
> This means that the only way ahead is to find some way of getting the information and using that to build a variadic version of mpl::find.
>
> Have you thought about this, or discussed it with Doug Gregor?

Nope.  However, I'm trying to solve the problem now.  I tried compiling
the mpl/test/find.cpp, but got very obscure error messages.  The
messages say something about and_ being incomplete, but that makes no
since because I just defined it as:

     template<class B0, class B1>
     struct and_binary
     : eval_if
       < B0
       , B1
       , false_
       >
     {
     };

     template<typename... B>
     struct and_
     : fold
       < package<B...>
       , true_
       , and_binary
         < arg<1>
         , arg<2>
         >
       >
     {
     };

Still working on it, but it's very hard to figure
out what's going wrong.  I've resorted to extracting
various subexpressions of the find expression to see
what is actually undefined.  It's going to take a while.
I'll let you know.

>
> Thanks for your work
>
Your welcome.

BTW, you mentioned in an earlier post that you'd done some FC++ work.
I've looked at haskell some and it appears monads could be used to
create a cross product.  AFAICT, a haskell list comprehension is like
a flattened cross product.  I mention that because I'd really be
interested in an mpl monad to see if it can be used to solve the
cross product problem mentioned in the MPL book.  One solution
is in the vault/Template Metaprogramming directory.
OTOH, I know you're busy, but still, I'd love to see alternative
solutions.  Who knows, since monads have also been used to
write parsers, it may come in handy for spirit also in the future.


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

Fletcher, John P
In reply to this post by cppljevans
Larry

Try this:

typedef mpl::vector<char,int,unsigned,long,unsigned long> types;

namespace experiment {

  // Following fold
  template <typename Sequence, typename Key, int N = 0>
  struct find;

  template <template < typename...> class Sequence,
            typename Head,
            typename... Tail,
            typename Key, int N>
  struct find < Sequence <Head, Tail... > , Key, N >
    : boost::mpl::if_<is_same<Head,Key>,
                      mpl::int_<N>,
                      find< Sequence <Tail...>, Key, N+1> >::type
  {
  };

  // End case.
  template <template < typename...> class Sequence,
            typename Head,
            typename Key, int N>
  struct find < Sequence <Head> , Key, N >
    : boost::mpl::if_<is_same<Head,Key>,
                      mpl::int_<N>,
                      mpl::void_>::type
  {
  };

}

typedef experiment::find<types,char> what0;
typedef experiment::find<types,int>  what1;
typedef experiment::find<types,long> what3;
typedef experiment::find<types,double> whatnot;
BOOST_MPL_ASSERT_RELATION( what0::value, ==, 0 );
BOOST_MPL_ASSERT_RELATION( what1::value, ==, 1 );
BOOST_MPL_ASSERT_RELATION( what3::value, ==, 3 );
BOOST_MPL_ASSERT(( is_same< whatnot::type, mpl::void_ > ));

It doesn't match the interface with pos::value which mpl has, but I guess that and the end value can be fixed.

What do you think?



________________________________________
From: Larry Evans [[hidden email]]
Sent: 02 February 2009 23:53
To: [hidden email]
Subject: Re: [Spirit-devel] FW: FW: [fusion] variadic mpl for use with fusion

On 02/02/09 17:16, Fletcher, John P wrote:
> Larry
>
> I need to thank you for your patience.

Sure,  Your most welcome.

> I see that quite a lot of what I have been writing about is all covered in your document of your experiences.
> I did read it when I first opened your files, but did not appreciate the significance of some of it until now.
>
> I realise now that the find operation is something which you have not yet covered, so it is hardly surprising it does not work.
>
> It is important for me as within the variadic tuple I am keen to provide good compiler error messages when the user does something wrong.
> I have done that within the internals using find to get back to the numeric location in the type bundle.

Better error messages would've helped me a great deal during the
conversion of mpl to use variadic templates.  Good luck!

>
> I have had a look at the implementation of tr1::tuple and the specification of boost::tuple and neither of those provide an equivalent.
>
> This means that the only way ahead is to find some way of getting the information and using that to build a variadic version of mpl::find.
>
> Have you thought about this, or discussed it with Doug Gregor?

Nope.  However, I'm trying to solve the problem now.  I tried compiling
the mpl/test/find.cpp, but got very obscure error messages.  The
messages say something about and_ being incomplete, but that makes no
since because I just defined it as:

     template<class B0, class B1>
     struct and_binary
     : eval_if
       < B0
       , B1
       , false_
       >
     {
     };

     template<typename... B>
     struct and_
     : fold
       < package<B...>
       , true_
       , and_binary
         < arg<1>
         , arg<2>
         >
       >
     {
     };

Still working on it, but it's very hard to figure
out what's going wrong.  I've resorted to extracting
various subexpressions of the find expression to see
what is actually undefined.  It's going to take a while.
I'll let you know.

>
> Thanks for your work
>
Your welcome.

BTW, you mentioned in an earlier post that you'd done some FC++ work.
I've looked at haskell some and it appears monads could be used to
create a cross product.  AFAICT, a haskell list comprehension is like
a flattened cross product.  I mention that because I'd really be
interested in an mpl monad to see if it can be used to solve the
cross product problem mentioned in the MPL book.  One solution
is in the vault/Template Metaprogramming directory.
OTOH, I know you're busy, but still, I'd love to see alternative
solutions.  Who knows, since monads have also been used to
write parsers, it may come in handy for spirit also in the future.


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

cppljevans
On 02/02/09 18:35, Fletcher, John P wrote:
> Larry
>
> Try this:
>
> typedef mpl::vector<char,int,unsigned,long,unsigned long> types;
[snip]

> typedef experiment::find<types,char> what0;
> typedef experiment::find<types,int>  what1;
> typedef experiment::find<types,long> what3;
> typedef experiment::find<types,double> whatnot;
> BOOST_MPL_ASSERT_RELATION( what0::value, ==, 0 );
> BOOST_MPL_ASSERT_RELATION( what1::value, ==, 1 );
> BOOST_MPL_ASSERT_RELATION( what3::value, ==, 3 );
> BOOST_MPL_ASSERT(( is_same< whatnot::type, mpl::void_ > ));
>
> It doesn't match the interface with pos::value which mpl has, but I guess that and the end value can be fixed.
>
> What do you think?
>

Great!  It's also pretty understandable.


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

Joel de Guzman-2
In reply to this post by Fletcher, John P
Fletcher, John P wrote:
> Larry
>
> I am working on it from the other end, starting from your fold and modifying it.
>
> I can't do copy and paste where I am at the moment.  I will send another message with some code in it in a minute.
>
> FC++ is a long story, I'll give you a reference in a minute.
>
Guys, please avoid top-posting. It's excruciatingly painful to follow
the threads.

Regaards,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

cppljevans
In reply to this post by cppljevans
On 02/02/09 19:03, Larry Evans wrote:
> On 02/02/09 18:35, Fletcher, John P wrote:
>> It doesn't match the interface with pos::value which mpl has, but I guess that and the end value can be fixed.
[snip]

What about:

   template <template < typename...> class Sequence,
             typename Key, int N>
   struct find < Sequence <> , Key, N >
     : mpl::int_<N+1>
   {
   };


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

cppljevans
In reply to this post by Fletcher, John P
On 02/02/09 18:35, Fletcher, John P wrote:
[snip]

>   template <template < typename...> class Sequence,
>             typename Head,
>             typename... Tail,
>             typename Key, int N>
>   struct find < Sequence <Head, Tail... > , Key, N >
>     : boost::mpl::if_<is_same<Head,Key>,
>                       mpl::int_<N>,
>                       find< Sequence <Tail...>, Key, N+1> >::type
>   {
>   };

Using eval_if instead of if_ is supposed to save some template
instantiations, IIUC, from reading:

http://www.boost.org/doc/libs/1_37_0/libs/mpl/doc/refmanual/eval-if.html

and section 4.1.2 (Lazy Type Selection) from the mpl book which says
(p.65):

   Whereas if_ *returns* one of two arguments ...
   eval_if *invokes* one of two nullary metafunction arguments.

[snip]


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: FW: FW: [fusion] variadic mpl for use with fusion

Fletcher, John P
In reply to this post by Joel de Guzman-2
From: Joel de Guzman [mailto:[hidden email]]
Sent: 03 February 2009 00:58
To: [hidden email]
Subject: Re: [Spirit-devel] FW: FW: [fusion] variadic mpl for use with fusion

Fletcher, John P wrote:
> Larry
>
> I am working on it from the other end, starting from your fold and modifying it.
>
> I can't do copy and paste where I am at the moment.  I will send another message with some code in it in a minute.
>
> FC++ is a long story, I'll give you a reference in a minute.
>
Guys, please avoid top-posting. It's excruciatingly painful to follow
the threads.

Regaards,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


-------------

Sorry, it is what my software does by default.  I will make up for it by summarizing the thread, which is mostly development in progress, which has now found a solution, so readers can see an example of two people who have not worked together before cooperating.

John

BTW this whole line, although it supports my work on variadic fusion, is really MPL.  Should the summary be cross posted and if so where?



------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
12