Scarab
v2.9.1
Project 8 C++ Utility Library
library
external
pybind11
tests
test_union.cpp
Go to the documentation of this file.
1
/*
2
tests/test_class.cpp -- test py::class_ definitions and basic functionality
3
4
Copyright (c) 2019 Roland Dreier <roland.dreier@gmail.com>
5
6
All rights reserved. Use of this source code is governed by a
7
BSD-style license that can be found in the LICENSE file.
8
*/
9
10
#include "
pybind11_tests.h
"
11
12
TEST_SUBMODULE
(
union_
, m) {
13
union
TestUnion {
14
int
value_int;
15
unsigned
value_uint;
16
};
17
18
py::class_<TestUnion>
(m,
"TestUnion"
)
19
.def(py::init<>())
20
.def_readonly(
"as_int"
, &TestUnion::value_int)
21
.
def_readwrite
(
"as_uint"
, &TestUnion::value_uint);
22
}
pybind11_tests.h
pybind11::class_
Definition:
pybind11.h:1038
union_
test_initializer union_("union_", test_submodule_union_)
TEST_SUBMODULE
#define TEST_SUBMODULE(name, variable)
Definition:
pybind11_tests.h:20
pybind11::class_::def_readwrite
class_ & def_readwrite(const char *name, D C::*pm, const Extra &... extra)
Definition:
pybind11.h:1186
Generated by
1.8.13