scool r150: mini-std: Add "Container" concept

URL: https://svn.lrde.epita.fr/svn/scool/branches/scool-ng ChangeLog: 2009-04-14 Warren Seine <soow@lrde.epita.fr> mini-std: Add "Container" concept. Still non-compiling. * c++/mini-std.hh: Add Container structure and associated traits. --- mini-std.hh | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 96 insertions(+), 8 deletions(-) Index: branches/scool-ng/examples/mini-std/c++/mini-std.hh =================================================================== --- branches/scool-ng/examples/mini-std/c++/mini-std.hh (revision 149) +++ branches/scool-ng/examples/mini-std/c++/mini-std.hh (revision 150) @@ -42,19 +42,16 @@ { namespace internal { + typedef char yes_; + struct no_ { char dummy[2]; }; + } // End of namespace internal } // End of namespace mstd -/*----------------------------. -| Automatic implementations. | -`----------------------------*/ - namespace mstd { - namespace behavior { struct identity; } - - // Forward declarations. + // Forward declaration. template <typename Exact> struct Container; @@ -64,8 +61,64 @@ template <typename Exact> struct Iterator; - // FIXME + // Container category flag type. + template <> + struct Container<void> + { + typedef Object<void> super; + }; +} + + +/*----------------------------. +| Traits. | +`----------------------------*/ + +namespace mstd +{ + namespace trait // mln/core/image/image2d.hh:94 + { + // Undefined property tag + struct undef { std::string name() const { return "undef"; } }; + + + template <typename C> + struct undefined_container_ // mln/trait/images.hh:134 + { + // misc + typedef undef category; + typedef undef speed; + typedef undef size; + + // data (I::value) + typedef undef kind; + typedef undef nature; + typedef undef quant; + }; + + + template <typename C> + struct container_ : undefined_container_<C> + { + }; + + + template <typename T, typename C> + struct default_container_ : undefined_container_<C> + { }; + } +} + + +/*----------------------------. +| Automatic implementations. | +`----------------------------*/ + +namespace mstd +{ +}; + /*---------------. | Abstractions. | @@ -81,6 +134,31 @@ // Container. // // ----------- // + // Base class for implementation of container classes + + template <typename E> + struct Container : public Object< E > + { + typedef Container<void> category; + + /* + // provided by internal::container_base: + + typedef value_t; + typedef size_t; + typedef stdcontainer_t; + + */ + + protected: + Container() + { + // FIXME: Add check just like in mln/core/concept/image.hh + } + }; + + template <typename E> struct Container; + template <typename Exact> struct Container : virtual public Any<Exact>, virtual public automatic::set_impl< Container, behavior::identity, Exact > @@ -189,6 +267,16 @@ template <typename T> struct list; + namespace trait // mln/core/image/image2d.hh:94 + { + template <typename T> + struct container_< list<T> > : default_container_< T, list<T> > + { + // misc + typedef trait::container::category::primary category; + }; + } + // FIXME: List implementation -- :: Warren Seine // SooW :: :: warren.seine @ gmail.com :: :: EPITA CSI 2010 ::
participants (1)
-
Warren Seine