diff --git a/doc/v2/containers.html b/doc/v2/containers.html index a687fafd..1dd023ea 100755 --- a/doc/v2/containers.html +++ b/doc/v2/containers.html @@ -55,6 +55,9 @@
Using policies
+
+ Visitor flag values +
Extending and customizing
@@ -217,9 +220,9 @@ BOOST_PYTHON_MODULE(example) {

- The top-level interface to the container suite is via the container_suite.hpp - header which is summarized below: + header is summarized below:

@@ -233,12 +236,20 @@ BOOST_PYTHON_MODULE(example) { namespace boost { namespace python { namespace indexing { typedef return_value_policy<return_by_value> default_container_policies; - template<class Container, class Algorithms = algo_selector<Container> > + template<class Container, + int Flags = 0, + class Algorithms = algo_selector<Container> > struct container_suite - : public visitor<Algorithms, default_container_policies> + : public visitor<Algorithms, default_container_policies, Flags> { + typedef Algorithms algorithms; + template<typename Policy> - static visitor<Algorithms, Policy> with_policies (Policy const &policy); + static visitor<Algorithms, Policy, Flags> + with_policies (Policy const &policy) + { + return visitor <Algorithms, Policy> (policy); + } }; } } } @@ -274,6 +285,14 @@ namespace boost { namespace python { namespace indexing { client-provided policies. +

  • + + The template parameter Flags allows client code + to disable unneeded features in order to reduce code + size. Details are provided below. + +
  • @@ -290,9 +309,10 @@ namespace boost { namespace python { namespace indexing { list.hpp, set.hpp and map.hpp. These correspond in the obvious way to the standard headers vector, deque, - etc. The header files for the container_proxy and - iterator_range templates provide their own support - implicitly. + etc. The header files for the container_proxy and iterator_range templates + provide their own support implicitly.

    @@ -370,6 +390,89 @@ namespace boost { namespace python { namespace indexing {

    +

    Visitor Flag values

    + +

    + + The container_suite template has an optional + Flags parameter that allows client code to disable + various optional features of the suite. This can lead to + significant savings in the size of object files and executables + if features such as sorting or Python slice support are not + needed. The Flags parameter (an integer) can be any + bitwise combination of the following values (defined in the + boost::python::indexing namespace by visitor.hpp): + +

    + +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FlagEffect
    disable_lenomits the Python __len__ method
    disable_slicesomits slice support code from __getitem__, + __setitem__ and __delitem__.
    disable_searchomits the container search methods count, + index and __contains__
    disable_reorderomits the container reordering operations + sort and reverse
    disable_extendomits the extend method
    disable_insertomits the insert method
    + +

    + +

    + + Note that some containers don't support some of the optional + features at all, in which case the relevant flags are + ignored. The value minimum_support may be passed as + a flag value to disable all optional features. A simple example + is provided in test_vector_disable.cpp + +

    +

    Extending and customizing

    @@ -2031,38 +2134,39 @@ namespace boost { namespace python { namespace indexing {

    - Note: the suite hasn't yet been tested on a compiler - without partial template specialization support. If you have any - results with such a compiler (good or bad) please report them on - the mailing list for the Python C++-SIG. + It is possible to use the suite without partial template + specialization support, but the algo_selector + specializations for the standard containers does not work. To + avoid this problem, the client code must explicitly select the + Algorithms and ContainerTraits + instances to be used, and there are some additional support + templates in the container-specific header files for this + purpose. + +

    +#include <boost/python/suite/indexing/vector.hpp>
    +
    +...
    +
    +  using namespace boost::python;
    +  using namespace boost::python::indexing;
    +
    +  class_<std::vector<int> > ("vector_int")
    +    .def (indexing::vector_suite <vector <int> >());
    +

    - It should be possible to use the suite without partial template - specialization support. However, the algo_selector - template will not work, which also means that the default - template parameter for container_suite won't - work. To avoid this problem, the client code must explicitly - select the Algorithms and - ContainerTraits instances to be used. It is - probably easiest to use the visitor template - directly, as in the following example: - -

    -  using namespace boost::python;
    -  using namespace boost::python::indexing;
    -
    -  class_<std::vector<int> > ("vector_int")
    -    .def (visitor <
    -           default_algorithms <
    -            default_sequence_traits <
    -             std::vector <int> > >,
    -           return_value_policy <return_by_value>
    -          >());
    -
    + Microsoft Visual C++ 6.0 has a version of the standard + deque header that is incompatible with the + container_proxy template, since it lacks a correct + template version of the insert member function. An + updated copy of the deque header that fixes this + problem (among others) is available directly from Dinkumware + (at time of writing, 2003/11/04).