Skip to content

Regression from v2.1.1 to v2.2.1 #1247

Closed
@daveah

Description

@daveah

Issue description

When moving from v2.1.1 to v2.2.1 a wrapper around a class with both std::vector and std::initializer_list templated constructors storing data in a boost variant no longer compiles.

Reproducible example code

#include "pybind11/pybind11.h"
#include <vector>
#include <initializer_list>
#include <boost/blank.hpp>
#include <boost/variant.hpp>

namespace py = pybind11;

class Foo {
public:
  template <typename TT>
  Foo(TT init) : Foo(std::vector<TT>(std::move(init))) {}
  template <typename TT>
  Foo(std::vector<TT> init) : _data(std::move(init)) {}
  template <typename TT>
  Foo(std::initializer_list<TT> init) : Foo(std::vector<TT>(init)) {}

private:
  using var = boost::variant<boost::blank, std::vector<uint32_t>>;

  var _data;
};

PYBIND11_PLUGIN(_foo) {
  py::module mm("_foo", "Foo");
  py::class_<Foo> foo(mm, "Foo");
  foo.def(py::init<uint32_t>());
  foo.def(py::init<std::vector<uint32_t>>());
  return mm.ptr();
};

Using boost 1.59, gcc 6.3.1 and python 3.5 this compiles fine with 2.1.1, but not with 2.2.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions