Make it possible to generate constexpr signatures in C++11 mode

The current C++14 constexpr signatures don't require relaxed constexpr,
but only `auto` return type deduction. To get around this in C++11,
the type caster's `name()` static member functions are turned into
`static constexpr auto` variables.
This commit is contained in:
Dean Moldovan
2017-07-02 11:48:56 +02:00
parent f94d759881
commit c10ac6cf1f
9 changed files with 103 additions and 178 deletions

View File

@@ -86,7 +86,7 @@ template <> struct type_caster<CopyOnlyInt> {
protected:
CopyOnlyInt value;
public:
static PYBIND11_DESCR name() { return _("CopyOnlyInt"); }
static constexpr auto name = _("CopyOnlyInt");
bool load(handle src, bool) { value = CopyOnlyInt(src.cast<int>()); return true; }
static handle cast(const CopyOnlyInt &m, return_value_policy r, handle p) { return pybind11::cast(m.value, r, p); }
static handle cast(const CopyOnlyInt *src, return_value_policy policy, handle parent) {