Request for mpl::empty_sequence

For the purpose of forward declaration of class templates this read-only lightweight sequence might be useful. For example, one might declare class template Selector in fwd file: // empty_sequence.hpp is designed for inclusion into fwd files #include <boost/mpl/empty_sequence.hpp> template<class Variants = empty_sequence> class Selector; Another way to archieve this could be inclusion of <boost/mpl/vector_fwd.hpp> (why there is no such file in mpl?) and using mpl::vector<> instead. Although, it could extend a set of class templates with those modifying template parameter but a user would find it strange to include <boost/mpl/vector.hpp> if he only uses Selector<>. The empty_sequence definition is as simple as: namespace boost { namespace mpl { namespace aux { struct empty_sequence_iter { typedef forward_iterator_tag category; }; } struct empty_sequence { typedef aux::empty_sequence_iter begin; typedef aux::empty_sequence_iter end; }; }} This is not yet complete. I hope that support for some transformations will be added later (transformation doesn't change empty_sequence unless the size is changed) -- Alexander Nasonov Independent Developer and Consultant

Alexander Nasonov writes:
For the purpose of forward declaration of class templates this read-only lightweight sequence might be useful. For example, one might declare class template Selector in fwd file:
// empty_sequence.hpp is designed for inclusion into fwd files #include <boost/mpl/empty_sequence.hpp>
template<class Variants = empty_sequence> class Selector;
Seems like a reasonable wish, somewhat correlating with 'single_view' (http://tinyurl.com/yqfp2). Why don't you write up the docs for it, and I'll put it in? A reference page template attached.
Another way to archieve this could be inclusion of <boost/mpl/vector_fwd.hpp> (why there is no such file in mpl?)
There wasn't a use case for it, I guess. The existing "_fwd" headers facilitale the proper physical layering of the library rather than anything else. IOW, they are not "user-oriented". Well, I guess a few of them, like "void_fwd.hpp" are; OTOH, the utility of that particular one is quite questionable -- given the size of the primary header, it might as well be a pessimization. In any case, I guess 'vector' is heavy-wegiht enough to have a forward declaration. If you are willing to make the refactoring, and submit the patch (preferrably in/against "mplbook" brach, http://tinyurl.com/26n24), I'll be happy to incorporate it.
and using mpl::vector<> instead. Although, it could extend a set of class templates with those modifying template parameter but a user would find it strange to include <boost/mpl/vector.hpp> if he only uses Selector<>.
You can go with 'vector0<>' and "boost/mpl/vector/vector0.hpp" correspondingly, which is a little bit more lightweight. But I agree, 'empty_sequence' is just cleaner, not as much performace POV as conceptually. [implementation snipped]
This is not yet complete. I hope that support for some transformations will be added later (transformation doesn't change empty_sequence unless the size is changed)
I am afraid I don't understand this part. -- Aleksey Gurtovoy MetaCommunications Engineering

Aleksey Gurtovoy wrote:
Alexander Nasonov writes:
For the purpose of forward declaration of class templates this read-only lightweight sequence might be useful. For example, one might declare class template Selector in fwd file:
// empty_sequence.hpp is designed for inclusion into fwd files #include <boost/mpl/empty_sequence.hpp>
template<class Variants = empty_sequence> class Selector;
Seems like a reasonable wish, somewhat correlating with 'single_view' (http://tinyurl.com/yqfp2). Why don't you write up the docs for it, and I'll put it in? A reference page template attached.
Ok. I'll do it.
This is not yet complete. I hope that support for some transformations will be added later (transformation doesn't change empty_sequence unless the size is changed)
I am afraid I don't understand this part.
I was trying to say that the following doesn't work transform_view<empty_sequence, add_pointer<_1> >. Any transformation that doesn't change the size of empty_sequence is certainly a trivial transformation. Why not allow it to compile? If I understand MPL philosophy correctly it's enough to add clear_traits specialization. -- Alexander Nasonov Independent Developer and Consultant

Rst file is ready. I can't check its correctness because I'm not familiar with this system yet. -- Alexander Nasonov Independent Developer and Consultant

Alexander Nasonov writes:
Rst file is ready. I can't check its correctness because I'm not familiar with this system yet.
Thank you! Could you put together the header as well? You can borrow the recommended copyright wording from http://tinyurl.com/2qpgg. Thanks, -- Aleksey Gurtovoy MetaCommunications Engineering

Aleksey Gurtovoy wrote:
Thank you! Could you put together the header as well? You can borrow the recommended copyright wording from http://tinyurl.com/2qpgg. Done. empty_sequence.rst - documentation empty_sequence.hpp - header empty_sequence.cpp - test -- Alexander Nasonov Independent Developer and Consultant

Alexander Nasonov writes:
Aleksey Gurtovoy wrote:
Thank you! Could you put together the header as well? You can borrow the recommended copyright wording from http://tinyurl.com/2qpgg. Done. empty_sequence.rst - documentation empty_sequence.hpp - header empty_sequence.cpp - test
Thank you! I'll get it integrated in the "mplbook" branch, which will go into the next release. -- Aleksey Gurtovoy MetaCommunications Engineering
participants (2)
-
Aleksey Gurtovoy
-
Alexander Nasonov