From c30304e85ed074bf4f186daef9d7d0d97199efdf Mon Sep 17 00:00:00 2001 From: Samuel Debionne Date: Thu, 9 Apr 2020 15:47:33 +0200 Subject: [PATCH] Update documentation --- doc/design/dynamic_image.rst | 84 +++++------------------------------- 1 file changed, 11 insertions(+), 73 deletions(-) diff --git a/doc/design/dynamic_image.rst b/doc/design/dynamic_image.rst index 7e50b91eae..f43c5eaffd 100644 --- a/doc/design/dynamic_image.rst +++ b/doc/design/dynamic_image.rst @@ -21,21 +21,18 @@ Here is an example: #define ASSERT_SAME(A,B) static_assert(is_same< A,B >::value, "") - // Define the set of allowed images - typedef mpl::vector my_images_t; - - // Create any_image class (or any_image_view) class - typedef any_image my_any_image_t; + // Create any_image class (or any_image_view) class with a set of allowed images + typedef any_image my_any_image_t; // Associated view types are available (equivalent to the ones in image_t) - typedef any_image_view > AV; + typedef any_image_view AV; ASSERT_SAME(my_any_image_t::view_t, AV); - typedef any_image_view > CAV; + typedef any_image_view> CAV; ASSERT_SAME(my_any_image_t::const_view_t, CAV); ASSERT_SAME(my_any_image_t::const_view_t, my_any_image_t::view_t::const_t); - typedef any_image_view > SAV; + typedef any_image_view SAV; ASSERT_SAME(typename dynamic_x_step_type::type, SAV); // Assign it a concrete image at run time: @@ -47,73 +44,15 @@ Here is an example: // Assigning to an image not in the allowed set throws an exception myImg = gray8_image_t(); // will throw std::bad_cast -The ``any_image`` and ``any_image_view`` subclass from GIL ``variant`` class, -which breaks down the instantiated type into a non-templated underlying base -type and a unique instantiation type identifier. The underlying base instance -is represented as a block of bytes. -The block is large enough to hold the largest of the specified types. - -GIL variant is similar to ``boost::variant`` in spirit (hence we borrow the -name from there) but it differs in several ways from the current boost -implementation. Perhaps the biggest difference is that GIL variant always -takes a single argument, which is a model of MPL Random Access Sequence -enumerating the allowed types. Having a single interface allows GIL variant -to be used easier in generic code. Synopsis: - -.. code-block:: cpp - - template // models MPL Random Access Container - class variant - { - ... _bits; - std::size_t _index; - public: - typedef Types types_t; - - variant(); - variant(const variant& v); - virtual ~variant(); - - variant& operator=(const variant& v); - template friend bool operator==(const variant& x, const variant& y); - template friend bool operator!=(const variant& x, const variant& y); - - // Construct/assign to type T. Throws std::bad_cast if T is not in Types - template explicit variant(const T& obj); - template variant& operator=(const T& obj); - - // Construct/assign by swapping T with its current instance. Only possible if they are swappable - template explicit variant(T& obj, bool do_swap); - template void move_in(T& obj); - - template static bool has_type(); - - template const T& _dynamic_cast() const; - template T& _dynamic_cast(); - - template bool current_type_is() const; - }; - - template - UOP::result_type apply_operation(variant& v, UOP op); - template - UOP::result_type apply_operation(const variant& v, UOP op); - - template - BOP::result_type apply_operation( variant& v1, variant& v2, UOP op); - - template - BOP::result_type apply_operation(const variant& v1, variant& v2, UOP op); - - template - BOP::result_type apply_operation(const variant& v1, const variant& v2, UOP op); +The ``any_image`` and ``any_image_view`` subclass from Boost.Variant2 ``variant`` class, +a never valueless variant type, compatible with ``std::variant`` in C++17. GIL ``any_image_view`` and ``any_image`` are subclasses of ``variant``: .. code-block:: cpp - template - class any_image_view : public variant + template + class any_image_view : public variant { public: typedef ... const_t; // immutable equivalent of this @@ -137,10 +76,9 @@ GIL ``any_image_view`` and ``any_image`` are subclasses of ``variant``: y_coord_t height() const; }; - template - class any_image : public variant + template + class any_image : public variant { - typedef variant parent_t; public: typedef ... const_view_t; typedef ... view_t;