[mpl, fusion] minimal conforming sequence

Hi, Assume that I have a custom type sequence S that has two operations, size<S>::value and element<S,I>::type (with whatever spelling). What needs to be done to adapt S into a conforming MPL or Fusion sequence? In a perfect world, the answer would not require the inclusion any MPL or Fusion headers and would consist of three specializations. ;-)

on Wed Aug 20 2008, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:
Hi,
Assume that I have a custom type sequence S that has two operations, size<S>::value and element<S,I>::type (with whatever spelling).
What needs to be done to adapt S into a conforming MPL or Fusion sequence?
In a perfect world, the answer would not require the inclusion any MPL or Fusion headers and would consist of three specializations. ;-)
Well, if it's an MPL sequence it's a fusion sequence, IIUC. So you need to decide which sequence to model http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/concepts.html According to http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/forward-sequence... you can make a forward sequence with 5 specializations. Please let me know if that's not enough information. -- Dave Abrahams BoostPro Computing http://www.boostpro.com

David Abrahams:
on Wed Aug 20 2008, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:
Hi,
Assume that I have a custom type sequence S that has two operations, size<S>::value and element<S,I>::type (with whatever spelling).
What needs to be done to adapt S into a conforming MPL or Fusion sequence?
In a perfect world, the answer would not require the inclusion any MPL or Fusion headers and would consist of three specializations. ;-)
Well, if it's an MPL sequence it's a fusion sequence, IIUC. So you need to decide which sequence to model http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/concepts.html
My original S is a random access sequence, so I'd probably want to model that.
According to http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/forward-sequence... you can make a forward sequence with 5 specializations.
That's manageable, but I'd need a random access iterator first. An integral constant, too, if I really don't want to include an MPL header. It would've been nice if I could just point MPL to size<> and element<> and tell it to build the rest of the required boilerplate. Patches welcome, you say? :-)

on Fri Aug 22 2008, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:
David Abrahams:
on Wed Aug 20 2008, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:
Hi,
Assume that I have a custom type sequence S that has two operations, size<S>::value and element<S,I>::type (with whatever spelling).
What needs to be done to adapt S into a conforming MPL or Fusion sequence?
In a perfect world, the answer would not require the inclusion any MPL or Fusion headers and would consist of three specializations. ;-)
Well, if it's an MPL sequence it's a fusion sequence, IIUC. So you need to decide which sequence to model http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/concepts.html
My original S is a random access sequence, so I'd probably want to model that.
According to http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/forward-sequence... you can make a forward sequence with 5 specializations.
That's manageable, but I'd need a random access iterator first. An integral constant, too, if I really don't want to include an MPL header. It would've been nice if I could just point MPL to size<> and element<> and tell it to build the rest of the required boilerplate. Patches welcome, you say? :-)
Always :-) -- Dave Abrahams BoostPro Computing http://www.boostpro.com

David Abrahams wrote:
on Fri Aug 22 2008, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:
David Abrahams:
on Wed Aug 20 2008, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:
Hi,
Assume that I have a custom type sequence S that has two operations, size<S>::value and element<S,I>::type (with whatever spelling).
What needs to be done to adapt S into a conforming MPL or Fusion sequence?
In a perfect world, the answer would not require the inclusion any MPL or Fusion headers and would consist of three specializations. ;-) Well, if it's an MPL sequence it's a fusion sequence, IIUC. So you need to decide which sequence to model http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/concepts.html My original S is a random access sequence, so I'd probably want to model that.
According to http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/forward-sequence... you can make a forward sequence with 5 specializations. That's manageable, but I'd need a random access iterator first. An integral constant, too, if I really don't want to include an MPL header. It would've been nice if I could just point MPL to size<> and element<> and tell it to build the rest of the required boilerplate. Patches welcome, you say? :-)
Always :-)
Ditto for Fusion, if you want to have values too. The "ideal" minimal, AFAICT, would be something like a specialization of: namespace boost { namespace fusion { namespace extension { template<typename S> struct random_access_sequence_adaptor; }}} with these minimal requirements: sequence::template size<Seq>::type sequence::template at_c<Seq, N>::type sequence::template at_c<Seq, N>::call(seq) (akin (and in addition to) http://tinyurl.com/6grjy9) I don't see any need for including any fusion headers with the interface above; just the forward declaration of random_access_sequence_adaptor. I can add this if time permits. Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net
participants (3)
-
David Abrahams
-
Joel de Guzman
-
Peter Dimov