[Spirit & Karma] #24: qi::optional test case should compile?

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

[Spirit & Karma] #24: qi::optional test case should compile?

Hartmut Kaiser
#24: qi::optional test case should compile?
--------------------+-------------------------------------------------------
 Reporter:  djowel  |       Owner:  djowel  
     Type:  defect  |      Status:  new      
 Priority:  major   |   Milestone:  Spirit V2
Component:  Spirit  |     Version:  Spirit V2
 Keywords:          |  
--------------------+-------------------------------------------------------
 See optional.cpp test case. This:

 {{{
     char ch;
     BOOST_TEST((test_attr(",c", -(',' >> char_), ch)));
     BOOST_TEST((ch == 'c'));
 }}}

 should probably compile?

--
Ticket URL: <http://fortytwo.cct.lsu.edu:8000/SpiritKarma/ticket/24>
Spirit &amp; Karma <http://spirit.sourceforge.net>
Development of the Boost::Spirit V2 libraries
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit & Karma] #24: qi::optional test case should compile?

Hartmut Kaiser
#24: qi::optional test case should compile?
---------------------+------------------------------------------------------
  Reporter:  djowel  |       Owner:  djowel  
      Type:  defect  |      Status:  new      
  Priority:  major   |   Milestone:  Spirit V2
 Component:  Spirit  |     Version:  Spirit V2
Resolution:          |    Keywords:          
---------------------+------------------------------------------------------
Comment (by hkaiser):

 Replying to [ticket:24 djowel]:
 > See optional.cpp test case. This:
 >
 {{{
     char ch;
     BOOST_TEST((test_attr(",c", -(',' >> char_), ch)));
     BOOST_TEST((ch == 'c'));
 }}}
 >
 > should probably compile?

 If we apply the rules, actually it should be:

 {{{
     fusion::vector<char> v;
     BOOST_TEST((test_attr(",c", -(',' >> char_), v)));
     BOOST_TEST((v == 'c'));
 }}}

 which compiles fine, BTW.

 There are two possible solutions, both of which I do not like very much.
 The first is to unpack the sequence result by default if it is a single
 element fusion sequence. The second is to add an overload of assign_to:

 {{{
     template <typename Attribute, typename T>
     inline void
     construct(Attribute& attr, fusion::vector<T>& val)
     {
         attr = at_c<0>(val);
     }
 }}}

--
Ticket URL: <http://fortytwo.cct.lsu.edu:8000/SpiritKarma/ticket/24#comment:1>
Spirit &amp; Karma <http://spirit.sourceforge.net>
Development of the Boost::Spirit V2 libraries
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit & Karma] #24: qi::optional test case should compile?

Hartmut Kaiser
In reply to this post by Hartmut Kaiser
#24: qi::optional test case should compile?
---------------------+------------------------------------------------------
  Reporter:  djowel  |       Owner:  djowel  
      Type:  defect  |      Status:  new      
  Priority:  major   |   Milestone:  Spirit V2
 Component:  Spirit  |     Version:  Spirit V2
Resolution:          |    Keywords:          
---------------------+------------------------------------------------------
Comment (by hkaiser):

 Replying to [comment:1 hkaiser]:
 > Replying to [ticket:24 djowel]:
 > > See optional.cpp test case. This:
 > >
 {{{
     char ch;
     BOOST_TEST((test_attr(",c", -(',' >> char_), ch)));
     BOOST_TEST((ch == 'c'));
 }}}
 > >
 > > should probably compile?
 >
 > If we apply the rules, actually it should be:
 >
 {{{
     fusion::vector<char> v;
     BOOST_TEST((test_attr(",c", -(',' >> char_), v)));
     BOOST_TEST((v == 'c'));
 }}}
 >
 > which compiles fine, BTW.
 >
 > There are two possible solutions, both of which I do not like very much.
 The first is to unpack the sequence result by default if it is a single
 element fusion sequence. The second is to add an overload of assign_to:
 >
 {{{
     template <typename Attribute, typename T>
     inline void
     construct(Attribute& attr, fusion::vector<T>& val)
     {
         attr = at_c<0>(val);
     }
 }}}
 >

 Doh! I have two typos in the first reply. The first is:

 {{{
     fusion::vector<char> v;
     BOOST_TEST((test_attr(",c", -(',' >> char_), v)));
     BOOST_TEST((fusion::at_c<0>(v) == 'c'));  // <--- here
 }}}

 The second is, that we could overload construct(), not assign_to().

--
Ticket URL: <http://fortytwo.cct.lsu.edu:8000/SpiritKarma/ticket/24#comment:2>
Spirit &amp; Karma <http://spirit.sourceforge.net>
Development of the Boost::Spirit V2 libraries
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel