hpp-python  6.1.0
python bindings for HPP, based on boost python
stl-pair.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_STD_PAIR_HH
31 #define PYHPP_STD_PAIR_HH
32 
33 #include <boost/python.hpp>
34 
35 namespace pyhpp {
36 template <typename T1, typename T2>
37 struct stl_pair {
38  typedef std::pair<T1, T2> pair_type;
39 
40  stl_pair(const char* name) {
41  using namespace boost::python;
42  class_<pair_type>(name, init<>())
43  .def(init<const T1&, const T2&>())
44  .def_readwrite("first", &pair_type::first)
45  .def_readwrite("second", &pair_type::second);
46  }
47 };
48 } // namespace pyhpp
49 
50 #endif // PYHPP_STD_PAIR_HH
Definition: fwd.hh:35
Definition: stl-pair.hh:37
std::pair< T1, T2 > pair_type
Definition: stl-pair.hh:38
stl_pair(const char *name)
Definition: stl-pair.hh:40