hpp-python  6.1.0
python bindings for HPP, based on boost python
vector-indexing-suite.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2018 CNRS
3 // Authors: Joseph Mirabel
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions
7 // are met:
8 
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 
12 // 2. Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 // OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 #ifndef PYHPP_VECTOR_INDEXING_SUITE_HH
31 #define PYHPP_VECTOR_INDEXING_SUITE_HH
32 
33 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
34 
35 namespace pyhpp {
36 template <class Container, bool NoProxy = false>
38  : public boost::python::vector_indexing_suite<
39  Container, NoProxy,
40  cpp_like_vector_indexing_suite<Container, NoProxy> > {
41  public:
42  typedef boost::python::vector_indexing_suite<Container, NoProxy,
45  template <class Class>
46  static void extension_def(Class& cl) {
47  base_type::extension_def(cl);
48 
49  cl.def("size", &base_type::size)
50  .def("empty", &empty)
51  .def("push_back", &base_type::append);
52  }
53 
54  static bool empty(Container const& container) { return container.empty(); }
55 };
56 } // namespace pyhpp
57 
58 #endif // PYHPP_VECTOR_INDEXING_SUITE_HH
Definition: vector-indexing-suite.hh:40
static void extension_def(Class &cl)
Definition: vector-indexing-suite.hh:46
boost::python::vector_indexing_suite< Container, NoProxy, cpp_like_vector_indexing_suite > base_type
Definition: vector-indexing-suite.hh:44
static bool empty(Container const &container)
Definition: vector-indexing-suite.hh:54
Definition: fwd.hh:35