[fusion] Sequence IO query

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

[fusion] Sequence IO query

Fletcher, John P
I have been developing an alternative object called a variadic tuple as a way of making it easy to extend boost fusion.  I wanted to make it easy to use the IO defined by boost/fusion/sequence/io and I have made some progress on this.  There is one point where I want a modification to be made to boost/fusion/sequence/io/detail/out.hpp.

For now, a variadic tuple is a templated object defined in namespace boost::fusion::variadic_tuple, for example:

  boost::fusion::variadic_tuple::vtuple<double,double> two_numbers(1.0,2.0);
  typedef boost::fusion::variadic_tuple::vtuple<double,double> two_numbers_type;



My work has consisted of adapting the definitions of the fusion extension mechanism so that the various things defined there all work on the vtuple, which makes it much easier to construct new extension objects for fusion.  There are some default keys (first, second etc) and also a way for programmers to define their own keys ( e.g. un, deux, trois ).



I wanted to extend this to io operators.  The following works fine:



  std::cout << two_numbers << std::endl;

The problem arises when I want the variadic tuple to have variadic tuple members.



 typedef boost::fusion::variadic_tuple::vtuple<two_numbers_type,two_numbers_type> two_vt_type;
 two_vt_type exvtvt(two_numbers,two_numbers);

 std::cout << "exvtvt = "<< exvtvt << std::endl;
This one fails as it cannot find the output operator<< for the inner calls.  I have solved this by adding the following code into boost/fusion/sequence/io/detail/out.hpp in namespace boost::fusion before the namespace detail.  It amounts to an advance declaration of the operator << which is not getting found.

    namespace operators
    {
        template <typename Sequence>
        inline typename
            enable_if<
               fusion::traits::is_sequence<Sequence>
              , std::ostream&
            >::type
        operator<<(std::ostream& os, Sequence const& seq);
    }



The interesting thing is that equivalent examples with boost::fusion::vector do not need such an alteration, which implies that I am missing something here and that my proposed modification should not be needed.



 typedef boost::fusion::vector<int,int> vec_2int_type;
 typedef boost::fusion::vector<vec_2int_type,vec_2int_type> vecvec_2int_type;

 vec_2int_type example1(1,2),example2(3,4);
 vecvec_2int_type exvecvec(example1,example2);
 std::cout << example1 << std::endl;
 std::cout << exvecvec << std::endl;
Any thoughts would be appreciated.



John Fletcher






------------------------------------------------------------------------------
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: [fusion] Sequence IO query

cppljevans
On 01/18/09 13:19, Fletcher, John P wrote:

 > I have been developing an alternative object called a variadic tuple
 > as a way of making it easy to extend boost fusion.  I wanted to make
 > it easy to use the IO defined by boost/fusion/sequence/io and I have
 > made some progress on this.  There is one point where I want a
 > modification to be made to boost/fusion/sequence/io/detail/out.hpp.

 >
 > For now, a variadic tuple is a templated object defined in namespace
 > boost::fusion::variadic_tuple, for example:
 >
 >     boost::fusion::variadic_tuple::vtuple<double,double>
 >   two_numbers(1.0,2.0);
 >     typedef boost::fusion::variadic_tuple::vtuple<double,double>
 >   two_numbers_type;


How is this any better than any of the already existing fusion
containers:

 
http://www.boost.org/doc/libs/1_37_0/libs/fusion/doc/html/fusion/container.html

which are sequences(i.e. non-associative, e.g. vector and list)?

 >
 > My work has consisted of adapting the definitions of the fusion
 > extension mechanism so that the various things defined there all
 > work on the vtuple, which makes it much easier to construct new
 > extension objects for fusion.

Could you elaborate, i.e. how does it make it easier?

 > There are some default keys (first, second etc) and also a way for
 > programmers to define their own keys ( e.g. un, deux, trois ).
 >

This can be done already with fusion::map, AFAICT.


------------------------------------------------------------------------------
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: [fusion] Sequence IO query

Fletcher, John P
These objects can have different members of different types e.g.

    variadic_tuple::vtuple<std::string,int> bert("bert", 99);
    std::cout << "at_c<0>(bert) = " << at_c<0>(bert) << std::endl;
    std::cout << "at_c<1>(bert) = " << at_c<1>(bert) << std::endl;

This process automates the construction of fusion extensions with heterogenous types.

I gave a homgeneous example showing the IO problem I was having (See header).

I have been trying out some further things and when applying iterator range to the objects I defined before, the last line below fails to find the output operator.

  typedef result_of::begin<two_vt_type>::type VT_A;
  typedef result_of::end<two_vt_type>::type VT_B;
  VT_A vt_a(exvtvt);
  VT_B vt_b(exvtvt);
  iterator_range<VT_A, VT_B> vt_full_range(vt_a, vt_b);
  std::cout << "vt_full_range = "  << vt_full_range << std::endl;
  // std::cout << vt_a << std::endl;

I have looked in vain for any definitions of the operators namespace in any of the other headers for e.g. view, vector etc.

John

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

On 01/18/09 13:19, Fletcher, John P wrote:

 > I have been developing an alternative object called a variadic tuple
 > as a way of making it easy to extend boost fusion.  I wanted to make
 > it easy to use the IO defined by boost/fusion/sequence/io and I have
 > made some progress on this.  There is one point where I want a
 > modification to be made to boost/fusion/sequence/io/detail/out.hpp.

 >
 > For now, a variadic tuple is a templated object defined in namespace
 > boost::fusion::variadic_tuple, for example:
 >
 >     boost::fusion::variadic_tuple::vtuple<double,double>
 >   two_numbers(1.0,2.0);
 >     typedef boost::fusion::variadic_tuple::vtuple<double,double>
 >   two_numbers_type;


How is this any better than any of the already existing fusion
containers:


http://www.boost.org/doc/libs/1_37_0/libs/fusion/doc/html/fusion/container.html

which are sequences(i.e. non-associative, e.g. vector and list)?

 >
 > My work has consisted of adapting the definitions of the fusion
 > extension mechanism so that the various things defined there all
 > work on the vtuple, which makes it much easier to construct new
 > extension objects for fusion.

Could you elaborate, i.e. how does it make it easier?

 > There are some default keys (first, second etc) and also a way for
 > programmers to define their own keys ( e.g. un, deux, trois ).
 >

This can be done already with fusion::map, AFAICT.


------------------------------------------------------------------------------
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: [fusion] Sequence IO query

cppljevans
On 01/18/09 14:42, Fletcher, John P wrote:
> These objects can have different members of different types e.g.
>
>     variadic_tuple::vtuple<std::string,int> bert("bert", 99);
>     std::cout << "at_c<0>(bert) = " << at_c<0>(bert) << std::endl;
>     std::cout << "at_c<1>(bert) = " << at_c<1>(bert) << std::endl;

How is this any different than the example at the bottom of:

http://www.boost.org/doc/libs/1_37_0/libs/fusion/doc/html/fusion/container/vector.html

other than the different type arguments to the template?

>
> This process automates the construction of fusion extensions with heterogenous types.

How?  The example shown above is not significantly different than
that shown on the vector.html webpage.

>
> I gave a homgeneous example showing the IO problem I was having (See header).

Your OP contained:

   > equivalent examples with boost::fusion::vector do not need such an
alteration,

Since fusion::vector solves the iterator problem, as you say in the OP,
why not just use fusion::vector?  I must be missing something :(


------------------------------------------------------------------------------
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: [fusion] Sequence IO query

Fletcher, John P
Larry

The reason I started out on this was because there was some discussion involving Joel that the variadic tuple (included in new developments in C++) would provide a way to implement a vector in fusion which would not be tied to the fixed size implementations which underly vector.

This thread was intended to be about me raising some queries about the mechanism and implementation.

John
________________________________________
From: Larry Evans [[hidden email]]
Sent: 18 January 2009 21:18
To: [hidden email]
Subject: Re: [Spirit-devel] [fusion] Sequence IO query

On 01/18/09 14:42, Fletcher, John P wrote:
> These objects can have different members of different types e.g.
>
>     variadic_tuple::vtuple<std::string,int> bert("bert", 99);
>     std::cout << "at_c<0>(bert) = " << at_c<0>(bert) << std::endl;
>     std::cout << "at_c<1>(bert) = " << at_c<1>(bert) << std::endl;

How is this any different than the example at the bottom of:

http://www.boost.org/doc/libs/1_37_0/libs/fusion/doc/html/fusion/container/vector.html

other than the different type arguments to the template?

>
> This process automates the construction of fusion extensions with heterogenous types.

How?  The example shown above is not significantly different than
that shown on the vector.html webpage.

>
> I gave a homgeneous example showing the IO problem I was having (See header).

Your OP contained:

   > equivalent examples with boost::fusion::vector do not need such an
alteration,

Since fusion::vector solves the iterator problem, as you say in the OP,
why not just use fusion::vector?  I must be missing something :(


------------------------------------------------------------------------------
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: [fusion] Sequence IO query

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

I forgot to say, as I have been using them for so long, that the sets of types (and arguments) can be packed up and passed in a pack.  This means that generic functions can be written to process them, provided the compiler supports this (e.g. gcc 4.3.0 with -std=gnu++0x).

John

P.S. Some messages seem to be taking more than an hour between dispatch and receipt.
________________________________________
From: Larry Evans [[hidden email]]
Sent: 18 January 2009 21:18
To: [hidden email]
Subject: Re: [Spirit-devel] [fusion] Sequence IO query

On 01/18/09 14:42, Fletcher, John P wrote:
> These objects can have different members of different types e.g.
>
>     variadic_tuple::vtuple<std::string,int> bert("bert", 99);
>     std::cout << "at_c<0>(bert) = " << at_c<0>(bert) << std::endl;
>     std::cout << "at_c<1>(bert) = " << at_c<1>(bert) << std::endl;

How is this any different than the example at the bottom of:

http://www.boost.org/doc/libs/1_37_0/libs/fusion/doc/html/fusion/container/vector.html

other than the different type arguments to the template?

>
> This process automates the construction of fusion extensions with heterogenous types.

How?  The example shown above is not significantly different than
that shown on the vector.html webpage.

>
> I gave a homgeneous example showing the IO problem I was having (See header).

Your OP contained:

   > equivalent examples with boost::fusion::vector do not need such an
alteration,

Since fusion::vector solves the iterator problem, as you say in the OP,
why not just use fusion::vector?  I must be missing something :(


------------------------------------------------------------------------------
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: [fusion] Sequence IO query

Joel de Guzman-2
Fletcher, John P wrote:
> Larry
>
> I forgot to say, as I have been using them for so long, that the sets of
> types (and arguments) can be packed up and passed in a pack.  This means that
> generic functions can be written to process them, provided the compiler
> supports this (e.g. gcc 4.3.0 with -std=gnu++0x).

I think this is a good direction. My current thinking is still to have
these variadic-savvy containers replace the ones fusion has for 0x capable
compilers. The good thing about John's work is that they are separate
from the rest of the fusion code. I'm not quite fond of having a single
code base poluted with tons of ifdefs especially in this case where
the code is significantly different. We can simply have them included
automatically once varaidic support is detected in the preprocessor.

As for the original question re >> and << not being detected, I think
it is because the containers you have reside in a different namespace
otside fusion. As sich, they are not considered by ADL.

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


------------------------------------------------------------------------------
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: [fusion] Sequence IO query

Fletcher, John P
Joel

Thank you for that.  I will have a look at moving my code into the correct namespace.

The problem with failure on operator<< is all the rubbish error messages telling me the alternatives.

Cheers

John
________________________________________
From: Joel de Guzman [[hidden email]]
Sent: 19 January 2009 00:57
To: [hidden email]
Subject: Re: [Spirit-devel] [fusion] Sequence IO query

Fletcher, John P wrote:
> Larry
>
> I forgot to say, as I have been using them for so long, that the sets of
> types (and arguments) can be packed up and passed in a pack.  This means that
> generic functions can be written to process them, provided the compiler
> supports this (e.g. gcc 4.3.0 with -std=gnu++0x).

I think this is a good direction. My current thinking is still to have
these variadic-savvy containers replace the ones fusion has for 0x capable
compilers. The good thing about John's work is that they are separate
from the rest of the fusion code. I'm not quite fond of having a single
code base poluted with tons of ifdefs especially in this case where
the code is significantly different. We can simply have them included
automatically once varaidic support is detected in the preprocessor.

As for the original question re >> and << not being detected, I think
it is because the containers you have reside in a different namespace
otside fusion. As sich, they are not considered by ADL.

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


------------------------------------------------------------------------------
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: [fusion] Sequence IO query

cppljevans
In reply to this post by Fletcher, John P
On 01/18/09 17:28, Fletcher, John P wrote:
 > Larry
 >
 > I forgot to say, as I have been using them for so long, that the
 > sets of types (and arguments) can be packed up and passed in a
 > pack.  This means that generic functions can be written to process
 > them, provided the compiler supports this (e.g. gcc 4.3.0 with
 > -std=gnu++0x).

Several months ago, I'd created a variadic verison of mpl which had
a template, package, which sounds like maybe it does this "packaging
of arguments" you mention above.  It's in the boost vault under the
variadic templates directory in mpl-vt.zip:

http://www.boostpro.com/vault/index.php?&directory=variadic_templates

 >
 > John
 >
 > P.S. Some messages seem to be taking more than an hour between
 > dispatch and receipt.

Thanks for the heads-up.


------------------------------------------------------------------------------
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: [fusion] Sequence IO query

Fletcher, John P
Larry

That looks very interesting.  I'll get it and have a look at it.

John

Dr John P. Fletcher Tel: (44) 121 204 3389 (direct line)
Chemical Engineering and Applied Chemistry (CEAC),
School of Engineering and Applied Science (SEAS),
Aston University, Aston Triangle, BIRMINGHAM B4 7ET  U.K.
CEAC Web site http://www.ceac.aston.ac.uk/  FAX: (44) 121 204 3679
-----Original Message-----
From: Larry Evans [mailto:[hidden email]]
Sent: 19 January 2009 03:11
To: [hidden email]
Subject: Re: [Spirit-devel] [fusion] Sequence IO query

On 01/18/09 17:28, Fletcher, John P wrote:
 > Larry
 >
 > I forgot to say, as I have been using them for so long, that the
 > sets of types (and arguments) can be packed up and passed in a
 > pack.  This means that generic functions can be written to process
 > them, provided the compiler supports this (e.g. gcc 4.3.0 with
 > -std=gnu++0x).

Several months ago, I'd created a variadic verison of mpl which had
a template, package, which sounds like maybe it does this "packaging
of arguments" you mention above.  It's in the boost vault under the
variadic templates directory in mpl-vt.zip:

http://www.boostpro.com/vault/index.php?&directory=variadic_templates

 >
 > John
 >
 > P.S. Some messages seem to be taking more than an hour between
 > dispatch and receipt.

Thanks for the heads-up.


------------------------------------------------------------------------------
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: [fusion] Sequence IO query

cppljevans
In reply to this post by Fletcher, John P
On 01/18/09 15:53, Fletcher, John P wrote:
 > Larry
 >
 > The reason I started out on this was because there was some
 > discussion involving Joel that the variadic tuple (included in new
 > developments in C++) would provide a way to implement a vector in
 > fusion which would not be tied to the fixed size implementations
 > which underly vector.
 >
John,

I'm unclear how not tying the fusion::vector to a fixed size
implmentatiion would be useful.  Could you provide an example?



------------------------------------------------------------------------------
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: [fusion] Sequence IO query

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

Thank you for the pointer to the variadic MPL.  I have had a look at it.

Which version of boost were you using?  Have you changed the code at all for the latest boost and also the newer compiler, gcc 4.3.0?

I am aware of some changes to mpl between boost 1.35.0 and 1.37.0 which hit me in my work on fusion, although fusion had not changed.

Also, how did you use your modified mpl?  It looks to me as though I am going to have to keep a complete copy of boost and put your files over it, as some have the same names.

Thanks again

John

(Strictly this is off topic for spirit devel, but I want to combine this with the work I am doing, which is spirit related.)

________________________________________
From: Larry Evans [[hidden email]]
Sent: 19 January 2009 03:10
To: [hidden email]
Subject: Re: [Spirit-devel] [fusion] Sequence IO query

On 01/18/09 17:28, Fletcher, John P wrote:
 > Larry
 >
 > I forgot to say, as I have been using them for so long, that the
 > sets of types (and arguments) can be packed up and passed in a
 > pack.  This means that generic functions can be written to process
 > them, provided the compiler supports this (e.g. gcc 4.3.0 with
 > -std=gnu++0x).

Several months ago, I'd created a variadic verison of mpl which had
a template, package, which sounds like maybe it does this "packaging
of arguments" you mention above.  It's in the boost vault under the
variadic templates directory in mpl-vt.zip:

http://www.boostpro.com/vault/index.php?&directory=variadic_templates

 >
 > John
 >
 > P.S. Some messages seem to be taking more than an hour between
 > dispatch and receipt.

Thanks for the heads-up.


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

------------------------------------------------------------------------------
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: [fusion] Sequence IO query

Fletcher, John P
In reply to this post by Joel de Guzman-2
I have moved my variadic tuple into namespace boost::fusion.  That did not resolve all the problems, but putting it into the same directory structure did resolve problems finding operator<<.  I think it must have been a question of the order of looking up the different headers, when included from different directory structures.

With the changes from another thread, I now have code which does not need any modification to other parts of boost fusion, and can drop in as a single header and a directory structure.  I am also cleaning it up of various development clutter.  I hope to have it soon in a form to contribute.

John
________________________________________
From: Joel de Guzman [[hidden email]]
Sent: 19 January 2009 00:57
To: [hidden email]
Subject: Re: [Spirit-devel] [fusion] Sequence IO query

Fletcher, John P wrote:
> Larry
>
> I forgot to say, as I have been using them for so long, that the sets of
> types (and arguments) can be packed up and passed in a pack.  This means that
> generic functions can be written to process them, provided the compiler
> supports this (e.g. gcc 4.3.0 with -std=gnu++0x).

I think this is a good direction. My current thinking is still to have
these variadic-savvy containers replace the ones fusion has for 0x capable
compilers. The good thing about John's work is that they are separate
from the rest of the fusion code. I'm not quite fond of having a single
code base poluted with tons of ifdefs especially in this case where
the code is significantly different. We can simply have them included
automatically once varaidic support is detected in the preprocessor.

As for the original question re >> and << not being detected, I think
it is because the containers you have reside in a different namespace
otside fusion. As sich, they are not considered by ADL.

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


------------------------------------------------------------------------------
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: [fusion] Sequence IO query

cppljevans
In reply to this post by Fletcher, John P
On 01/25/09 16:00, Fletcher, John P wrote:
 > Larry
 >
 > Thank you for the pointer to the variadic MPL.  I have had a look at
 > it.

[snip]
 >
 > Which version of boost were you using?  Have you changed the code at
 > all for the latest boost and also the newer compiler, gcc 4.3.0?

I don't remember which version.  I'm guessing it was whatever version
was current at the
time the files were uploaded to the vault.

I'll see if I can get it to compile with the current version.
 > I am aware of some changes to mpl between boost 1.35.0 and 1.37.0
 > which hit me in my work on fusion, although fusion had not changed.
 > Also, how did you use your modified mpl?  It looks to me as though I
 > am going to have to keep a complete copy of boost and put your files
 > over it, as some have the same names.

IIRC, I just included the variadic template mpl directory in front of
the regular boost directory.

Here's a portion of my current user-config.jam:

using gcc
  : 4.3_20080306_v
  : "/home/evansl/download/gcc/4.3-20080306/install/bin/g++"
  :
<cxxflags>-I/home/evansl/prog_dev/boost-svn/ro/trunk/boost/sandbox/variadic-templates
    <cxxflags>-std=gnu++0x
  ;

However, I'm not sure the 20080306 version of gcc was the one I actually ran
the tests on.  I remember using several versions of the gcc compiler.

I also *may* have gotten it to compile by having a Jamfile starting
with something like:

project sandbox
  : requirements
    <include>../variadic-templates&&..
  : usage-requirements
    <include>../variadic-templates&&..
  : build-dir ../bin.v2/sandbox
  : default-build debug
  ;

The && operator in teh <include> lines is supposed to order the
include directores. The .. directory is the normal boost root.

Again, I'll see if I can get it to compile now and let you know.
[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
Reply | Threaded
Open this post in threaded view
|

Re: [fusion] Sequence IO query

cppljevans
On 01/25/09 19:33, Larry Evans wrote:
[snip]
>
> Again, I'll see if I can get it to compile now and let you know.
Got the attached to compile with the gcc downloaded from:

ftp://gcc.gnu.org/pub/gcc/snapshots/4.4-20090109/gcc-4.4-20090109.tar.bz2

The compile was done with make as shown in 2nd attachment.

HTH.

-Larry


//test fold of variadic version of mpl vector.
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>

    typedef
  long
integral_type
;  

using namespace boost;

  template
  < class LeftIntC
  , class RightIntC
  >
  struct
reduce_plus
  : mpl::integral_c<integral_type,LeftIntC::value+RightIntC::value>
{
};

    typedef
  mpl::vector
  < mpl::integral_c<integral_type,1>
  , mpl::integral_c<integral_type,2>
  , mpl::integral_c<integral_type,3>
  >
seq3
;
    typedef
  mpl::fold
  < seq3
  , mpl::integral_c<integral_type,0>
  , reduce_plus
    < mpl::arg<1>
    , mpl::arg<2>
    >
  >::type
reduce_plus_1_2_3
;
    typedef
  mpl::integral_c
  < integral_type
  , reduce_plus_1_2_3::value
  >
integral_c_reduce_plus_1_2_3
;
BOOST_MPL_ASSERT((is_same<integral_c_reduce_plus_1_2_3, mpl::integral_c<integral_type,6> >));

  template
  < class Summand
  , class SumPartial
  >
struct scan_plus
;
  template
  < integral_type Summand
  , class SumPartial
  >
struct scan_plus
  < mpl::integral_c<integral_type,Summand>
  , SumPartial
  >
  : public SumPartial
{
        typedef
      SumPartial
    super_type
    ;
        static
      integral_type const
    value=Summand+SumPartial::value
    ;
        typedef
      scan_plus
    type
    ;
};
    typedef
  mpl::fold
  < seq3
  , mpl::integral_c<integral_type,0>
  , scan_plus
    < mpl::arg<1>
    , mpl::arg<2>
    >
  >::type
scan_plus_1_2_3
;
BOOST_MPL_ASSERT_RELATION(scan_plus_1_2_3::value,==,6);
BOOST_MPL_ASSERT_RELATION(scan_plus_1_2_3::super_type::value,==,3);
BOOST_MPL_ASSERT_RELATION(scan_plus_1_2_3::super_type::super_type::value,==,1);
BOOST_MPL_ASSERT_RELATION(scan_plus_1_2_3::super_type::super_type::super_type::value,==,0);

-*- mode: compilation; default-directory: "~/prog_dev/boost-svn/ro/boost-trunk/sandbox/variadic-templates/libs/mpl/test/" -*-
Compilation started at Sun Jan 25 21:30:01

make o
install -d /home/evansl/prog_dev/boost-svn/ro/boost-trunk/sandbox/build/gcc4_4v/variadic-templates/libs/mpl/test
/home/evansl/download/gcc/4.4-20090109/install/bin/g++ -c -std=gnu++0x -Wall -ftemplate-depth-100 -O0 -fno-inline -I/home/evansl/prog_dev/boost-svn/ro/boost-trunk/sandbox/variadic-templates -I/home/evansl/prog_dev/boost-svn/ro/boost-trunk  fold_test.cpp -o /home/evansl/prog_dev/boost-svn/ro/boost-trunk/sandbox/build/gcc4_4v/variadic-templates/libs/mpl/test/fold_test.o -MMD
sed -e 's#^fold_test.o:#/home/evansl/prog_dev/boost-svn/ro/boost-trunk/sandbox/build/gcc4_4v/variadic-templates/libs/mpl/test/fold_test.o:#' /home/evansl/prog_dev/boost-svn/ro/boost-trunk/sandbox/build/gcc4_4v/variadic-templates/libs/mpl/test/fold_test.d> /home/evansl/prog_dev/boost-svn/ro/boost-trunk/sandbox/build/gcc4_4v/variadic-templates/libs/mpl/test/fold_test.o.dep
rm /home/evansl/prog_dev/boost-svn/ro/boost-trunk/sandbox/build/gcc4_4v/variadic-templates/libs/mpl/test/fold_test.d

Compilation finished at Sun Jan 25 21:30:02

------------------------------------------------------------------------------
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: [fusion] Sequence IO query

Fletcher, John P
Larry

I got that one to work with gcc 4.3.0 and went to the others in your lib/boost/mpl/test directory.  They all compile except for package_c_test which causes a compiler internal error as follows:

/opt/gcc-4.3.0/bin/g++ -std=gnu++0x -I/home/fletchjp/mpl -I/home/fletchjp/boost_1_37_0 -O2 -Wl,-rpath -Wl,/opt/gcc-4.3.0/lib package_c_test.cpp -opackage_c_test
/home/fletchjp/mpl/boost/mpl/package_c_ops.hpp: In instantiation of øboost::mpl::push_front_c_impl<boost::mpl::package_c_tag>::apply<boost::mpl::package_c<A, a0, a1, a2>, a3>ù:
/home/fletchjp/mpl/boost/mpl/push_front_c.hpp:14:   instantiated from øboost::mpl::push_front_c<boost::mpl::package_c<A, a0, a1, a2>, a3>ù
package_c_test.cpp:59:   instantiated from øpkg_test<boost::mpl::package_c<A, a0, a1, a2>, boost::mpl::package_c<A, a3, a0, a1, a2>, boost::mpl::package_c<A, a0, a1, a2, a3> >ù
package_c_test.cpp:126:   instantiated from here
/home/fletchjp/mpl/boost/mpl/package_c_ops.hpp:338: internal compiler error: in dependent_type_p, at cp/pt.c:15558
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make: *** [package_c_test] Error 1

Your file was modified to include a small main program at the end, but otherwise unchanged. This worked on all the others where there was no main.

// Put in to make an executable.
main()
{
}

I have not reported this to gnu.  I have not had a chance to run this with gcc 4.4

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

John

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

On 01/25/09 19:33, Larry Evans wrote:
[snip]
>
> Again, I'll see if I can get it to compile now and let you know.
Got the attached to compile with the gcc downloaded from:

ftp://gcc.gnu.org/pub/gcc/snapshots/4.4-20090109/gcc-4.4-20090109.tar.bz2

The compile was done with make as shown in 2nd attachment.

HTH.

-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: [fusion] Sequence IO query

cppljevans
On 01/26/09 17:03, Fletcher, John P wrote:
[snip]
> Larry
>
> I got that one to work with gcc 4.3.0 and went to the others in your lib/boost/mpl/test directory.  They all compile except for package_c_test which causes a compiler internal error as follows:
>
[snip]

> /home/fletchjp/mpl/boost/mpl/package_c_ops.hpp:338: internal compiler error: in dependent_type_p, at cp/pt.c:15558
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <http://gcc.gnu.org/bugs.html> for instructions.
> make: *** [package_c_test] Error 1
>
> Your file was modified to include a small main program at the end, but otherwise unchanged. This worked on all the others where there was no main.
>
> // Put in to make an executable.
> main()
> {
> }

There's no need to run main since all errors are found at compile-time.
I think you'll find that's what the standard mpl tests do.

>
> 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
Reply | Threaded
Open this post in threaded view
|

Re: [fusion] Sequence IO query

cppljevans
In reply to this post by Fletcher, John P
On 01/26/09 17:03, Fletcher, John P wrote:
> Larry
>
> I got that one to work with gcc 4.3.0 and went to the others in your lib/boost/mpl/test directory.

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

John,

You might find the tupmap_index.hpp file in the mpl-vt.zip interesting.
It defines a tuple, implemented using inheritance (1 supertype for each
tuple element), and it also uses enumerators instead of int
for the at arguments.  IOW, unlike at_c<1> with fusion, as shown
here:

http://www.boost.org/doc/libs/1_37_0/libs/fusion/doc/html/fusion/container/vector.html

for a tuple declared as:

   enum
enum_indices
{ enum_0
, enum_1
, enum_2
};
   tupmap_indexed
   < package
     < T0
     , T1
     , T2
     >
   , enum_indices
   >
a_tuple
;

T0 a_to=a_tuple.template at_value<enum_0>();

where T0,...T2 are arbitrary types.

There are disadvantages w.r.t. fusion::vector.  One is that
it takes more room because of the inheritance implementation:

http://article.gmane.org/gmane.comp.lib.boost.devel/61417/match=alternative+tuple

The other may be that it takes more compile time because of
more template instantiations.  However, I've never run any
benchmarks to test that theory.

tupmap_indexed also uses the non-standard g++ typeof; however,
boost has an implmentation of this and the next standard
is supposed to have some equivalent (decltype or something
like that).


------------------------------------------------------------------------------
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