Welcome to mirror list, hosted at ThFree Co, Russian Federation.

vector_list_conversion.hpp « pyhelpers - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2aa12a9c615984dc57b097c466acb91aa6df2cf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once

#include "std/vector.hpp"

#include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp>

namespace
{
template <typename T>
vector<T> python_list_to_std_vector(boost::python::object const & iterable)
{
  return vector<T>(boost::python::stl_input_iterator<T>(iterable),
                   boost::python::stl_input_iterator<T>());
}

template <typename T>
boost::python::list std_vector_to_python_list(vector<T> const & v)
{
  boost::python::object get_iter = boost::python::iterator<vector<T>>();
  return boost::python::list(get_iter(v));
}
}  // namespace