Re: [Boost-users] [boost] [switch_] Case Concept [ was Re: formal review of Switch library...]
AMDG Tobias Schwinger wrote:
Joel de Guzman wrote:
c0, c1, ... cN Returns a fusion sequence of Case objects
seemingly equivalent to
(c0, c1, ... cN)
(note: Application of comma operator ;-)).
?! Why doesn't it just return another (compound) Case object and leave the Sequence an unspecified implementation detail...
So you want switch_ to be
template
Steven Watanabe wrote:
AMDG
Tobias Schwinger wrote:
Joel de Guzman wrote:
c0, c1, ... cN Returns a fusion sequence of Case objects
seemingly equivalent to
(c0, c1, ... cN)
(note: Application of comma operator ;-)).
?! Why doesn't it just return another (compound) Case object and leave the Sequence an unspecified implementation detail...
So you want switch_ to be
template
requires Case<Cases> && BuiltInIntegerOrEnum<I> R switch(I i, Cases cases); IMO, There is a very big problem here. Suppose that you have a fusion sequence that holds your cases and function objects coming from somewhere else. The problem of adapting it to switch_ is no easier than it would be with my original interface.
Oh man, either my headache is killing me, or I am currently in dumb mode. I can't understand both Tobias and Steven. What's a "compound Case object"? Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Joel de Guzman wrote:
Steven Watanabe wrote:
AMDG
Tobias Schwinger wrote:
Joel de Guzman wrote:
c0, c1, ... cN Returns a fusion sequence of Case objects
seemingly equivalent to
(c0, c1, ... cN)
(note: Application of comma operator ;-)).
?! Why doesn't it just return another (compound) Case object and leave the Sequence an unspecified implementation detail...
So you want switch_ to be
template
requires Case<Cases> && BuiltInIntegerOrEnum<I> R switch(I i, Cases cases); IMO, There is a very big problem here. Suppose that you have a fusion sequence that holds your cases and function objects coming from somewhere else. The problem of adapting it to switch_ is no easier than it would be with my original interface.
Oh man, either my headache is killing me, or I am currently in dumb mode. I can't understand both Tobias and Steven. What's a "compound Case object"?
(c0,c1,...,cN) being just another 'Case' rather than a 'Sequence'. Regards, Tobias
Tobias Schwinger wrote:
Joel de Guzman wrote:
Steven Watanabe wrote:
AMDG
Tobias Schwinger wrote:
Joel de Guzman wrote:
c0, c1, ... cN Returns a fusion sequence of Case objects
seemingly equivalent to
(c0, c1, ... cN)
(note: Application of comma operator ;-)).
?! Why doesn't it just return another (compound) Case object and leave the Sequence an unspecified implementation detail...
So you want switch_ to be
template
requires Case<Cases> && BuiltInIntegerOrEnum<I> R switch(I i, Cases cases); IMO, There is a very big problem here. Suppose that you have a fusion sequence that holds your cases and function objects coming from somewhere else. The problem of adapting it to switch_ is no easier than it would be with my original interface. Oh man, either my headache is killing me, or I am currently in dumb mode. I can't understand both Tobias and Steven. What's a "compound Case object"?
(c0,c1,...,cN) being just another 'Case' rather than a 'Sequence'.
o..k... Hmm.. so how would the resulting case object for this expression look like: case_c<1>(f1), case_c<2>(f2) ? Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Joel de Guzman wrote:
Tobias Schwinger wrote:
Joel de Guzman wrote:
Steven Watanabe wrote:
AMDG
Tobias Schwinger wrote:
Joel de Guzman wrote:
c0, c1, ... cN Returns a fusion sequence of Case objects
seemingly equivalent to
(c0, c1, ... cN)
(note: Application of comma operator ;-)).
?! Why doesn't it just return another (compound) Case object and leave the Sequence an unspecified implementation detail...
So you want switch_ to be
template
requires Case<Cases> && BuiltInIntegerOrEnum<I> R switch(I i, Cases cases); IMO, There is a very big problem here. Suppose that you have a fusion sequence that holds your cases and function objects coming from somewhere else. The problem of adapting it to switch_ is no easier than it would be with my original interface. Oh man, either my headache is killing me, or I am currently in dumb mode. I can't understand both Tobias and Steven. What's a "compound Case object"? (c0,c1,...,cN) being just another 'Case' rather than a 'Sequence'.
o..k... Hmm.. so how would the resulting case object for this expression look like:
case_c<1>(f1), case_c<2>(f2)
?
template< class SeqCases > struct sequenced_case { SeqCases seq_cases; typedef SeqCases seq_cases_t; sequenced_case(SeqCases const& s) : seq_cases(s) { } typedef mpl::transform_view< SeqCases, fusion::result_of::first<_> > labels; template< typename Result, class I > Result apply(I const&) { return fusion::at<I>(this->seq_cases); } }; If case_c<1>(f1) has the type C1 and case_c<2>(f2) has the type C2 the comma operator's result type is sequenced_case< joint_viewC1::seq_cases_t,C2:::seq_cases_t > 'seq_cases_t' would not have to be part of the Concept, because 'switch_' doesn't care about it. Regards, Tobias
Tobias Schwinger wrote:
(c0,c1,...,cN) being just another 'Case' rather than a 'Sequence'. o..k... Hmm.. so how would the resulting case object for this expression look like:
case_c<1>(f1), case_c<2>(f2)
?
template< class SeqCases > struct sequenced_case { SeqCases seq_cases;
typedef SeqCases seq_cases_t;
sequenced_case(SeqCases const& s) : seq_cases(s) { }
typedef mpl::transform_view< SeqCases, fusion::result_of::first<_> > labels;
template< typename Result, class I > Result apply(I const&) { return fusion::at<I>(this->seq_cases); } };
If case_c<1>(f1) has the type C1 and case_c<2>(f2) has the type C2 the comma operator's result type is
sequenced_case< joint_viewC1::seq_cases_t,C2:::seq_cases_t >
'seq_cases_t' would not have to be part of the Concept, because 'switch_' doesn't care about it.
Sounds good to me! I like it. So, this involves the variation where a case has an MPL sequence of labels. I knew there's something in that that I like. Intuition, I guess. That is also why I use the name case_ regardless of number. A compound case is just another case anyway. Does not matter how many labels it serves. Not sure how, implementation-wise, this works for Steven. Steven? If this pans out, I'll refine the concept one more time. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
AMDG Joel de Guzman wrote:
Tobias Schwinger wrote:
(c0,c1,...,cN) being just another 'Case' rather than a 'Sequence'.
o..k... Hmm.. so how would the resulting case object for this expression look like:
case_c<1>(f1), case_c<2>(f2)
?
template< class SeqCases > struct sequenced_case { <snip>
Sounds good to me! I like it. So, this involves the variation where a case has an MPL sequence of labels. I knew there's something in that that I like. Intuition, I guess. That is also why I use the name case_ regardless of number. A compound case is just another case anyway. Does not matter how many labels it serves.
Not sure how, implementation-wise, this works for Steven. Steven? If this pans out, I'll refine the concept one more time.
It's trivial to implement:
#define BOOST_SWITCH_CASE(z, n, data)\
case mpl::at_c
participants (3)
-
Joel de Guzman
-
Steven Watanabe
-
Tobias Schwinger