* Added arg/return type handling.
* Added support for nested arg/return type in py::typing::List
* Added support for arg/return type in stl/filesystem
* Added tests for arg/return type in stl/filesystem and py::typing::List
* Added arg/return name to more py::typing classes
* Added arg/return type to Callable[...]
* Added tests for typing container classes (also nested)
* Changed typing classes to avoid using C++14 auto return type deduction.
* Fixed clang-tidy errors.
* Changed Enable to SFINAE
* Added test for Tuple[T, ...]
* Added RealNumber with custom caster for testing typing classes.
* Added tests for Set, Iterable, Iterator, Union, and Optional
* Added tests for Callable
* Fixed Callable with ellipsis test
* Changed TypeGuard/TypeIs to use return type (being the narrower type) + Tests
* Added test for use of fallback type name with stl vector
* Updated documentation.
* Fixed unnecessary constructor call in test.
* Fixed reference counting in example type caster.
* Fixed clang-tidy issues.
* Fix for clang-tidy
* Updated cast method to use pybind11 API rather than Python C API in custom caster example
* Updated load to use pybind11 API rather than Python C API in custom caster example
* Changed test of arg/return name to use pybind11 API instead of Python C API
* Updated code in adcanced/cast example and improved documentation text
* Fixed references in custom type caster docs
* Fixed wrong logical and operator in test
* Fixed wrong logical operator in doc example
* Added comment to test about `float` vs `float | int`
* Updated std::filesystem::path docs in cast/overview section
* Remove one stray dot.
---------
Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
* chore: drop Python 3.5 support
* chore: more fstrings with flynt's help
* ci: drop Python 3.5
* chore: bump dependency versions
* docs: touch up py::args
* tests: remove deprecation warning
* Ban smartquotes
* Very minor tweaks (by-product of reviewing PR #3719).
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
* Propagate unicode conversion failure
If returning a std::string with invalid utf-8 data, we currently fail
with an uninformative TypeError instead of propagating the
UnicodeDecodeError that Python sets on failure.
* Add support for u16/u32strings and literals
This adds support for wchar{16,32}_t character literals and the
associated std::u{16,32}string types. It also folds the
character/string conversion into a single type_caster template, since
the type casters for string and wstring were mostly the same anyway.
* Added too-long and too-big character conversion errors
With this commit, when casting to a single character, as opposed to a
C-style string, we make sure the input wasn't a multi-character string
or a single character with codepoint too large for the character type.
This also changes the character cast op to CharT instead of CharT& (we
need to be able to return a temporary decoded char value, but also
because there's little gained by bothering with an lvalue return here).
Finally it changes the char caster to 'has-a-string-caster' instead of
'is-a-string-caster' because, with the cast_op change above, there's
nothing at all gained from inheritance. This also lets us remove the
`success` from the string caster (which was only there for the char
caster) into the char caster itself. (I also renamed it to 'none' and
inverted its value to better reflect its purpose). The None -> nullptr
loading also now takes place only under a `convert = true` load pass.
Although it's unlikely that a function taking a char also has overloads
that can take a None, it seems marginally more correct to treat it as a
conversion.
This commit simplifies the size assumptions about character sizes with
static_asserts to back them up.
Following commit 90d278, the object code generated by the python
bindings of nanogui (github.com/wjakob/nanogui) went up by a whopping
12%. It turns out that that project has quite a few enums where we don't
really care about arithmetic operators.
This commit thus partially reverts the effects of #503 by introducing
an additional attribute py::arithmetic() that must be specified if the
arithmetic operators are desired.
* Add type caster for std::experimental::optional
* Add tests for std::experimental::optional
* Support both <optional> / <experimental/optional>
* Mention std{::experimental,}::optional in the docs