pybind11/example
Jason Rhinelander 3f589379ec Improve constructor/destructor tracking
This commit rewrites the examples that look for constructor/destructor
calls to do so via static variable tracking rather than output parsing.

The added ConstructorStats class provides methods to keep track of
constructors and destructors, number of default/copy/move constructors,
and number of copy/move assignments.  It also provides a mechanism for
storing values (e.g. for value construction), and then allows all of
this to be checked at the end of a test by getting the statistics for a
C++ (or python mapping) class.

By not relying on the precise pattern of constructions/destructions,
but rather simply ensuring that every construction is matched with a
destruction on the same object, we ensure that everything that gets
created also gets destroyed as expected.

This replaces all of the various "std::cout << whatever" code in
constructors/destructors with
`print_created(this)`/`print_destroyed(this)`/etc. functions which
provide similar output, but now has a unified format across the
different examples, including a new ### prefix that makes mixed example
output and lifecycle events easier to distinguish.

With this change, relaxed mode is no longer needed, which enables
testing for proper destruction under MSVC, and under any other compiler
that generates code calling extra constructors, or optimizes away any
constructors.  GCC/clang are used as the baseline for move
constructors; the tests are adapted to allow more move constructors to
be evoked (but other types are constructors much have matching counts).

This commit also disables output buffering of tests, as the buffering
sometimes results in C++ output ending up in the middle of python
output (or vice versa), depending on the OS/python version.
2016-08-11 18:16:04 -04:00
..
CMakeLists.txt Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
constructor-stats.h Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
eigen.cpp Eigen support for special matrix objects 2016-08-04 15:24:41 -04:00
eigen.py Adopt PEP 484 type hints for C++ types exported to Python 2016-08-04 23:47:07 +02:00
eigen.ref Adopt PEP 484 type hints for C++ types exported to Python 2016-08-04 23:47:07 +02:00
example-arg-keywords-and-defaults.cpp Use generic arg names for functions without explicitly named arguments 2016-08-04 23:45:24 +02:00
example-arg-keywords-and-defaults.py Use generic arg names for functions without explicitly named arguments 2016-08-04 23:45:24 +02:00
example-arg-keywords-and-defaults.ref Adopt PEP 484 type hints for C++ types exported to Python 2016-08-04 23:47:07 +02:00
example-buffers.cpp Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-buffers.py Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-buffers.ref Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-callbacks.cpp Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-callbacks.py Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-callbacks.ref Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-constants-and-functions.cpp Fix scoped enums and add scoped enum example 2016-08-04 00:01:39 -04:00
example-constants-and-functions.py Only support ==/!= int on unscoped enums 2016-08-04 00:21:37 -04:00
example-constants-and-functions.ref Only support ==/!= int on unscoped enums 2016-08-04 00:21:37 -04:00
example-custom-exceptions.cpp Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-custom-exceptions.py Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-custom-exceptions.ref Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-eval.cpp Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-eval.py Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-eval.ref Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-eval_call.py Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-inheritance.cpp Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-inheritance.py Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-inheritance.ref Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-keep-alive.cpp Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-keep-alive.py Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-keep-alive.ref Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-methods-and-attributes.cpp Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-methods-and-attributes.py Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-methods-and-attributes.ref Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-modules.cpp Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-modules.py Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-modules.ref Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-numpy-vectorize.cpp Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-numpy-vectorize.py Adopt PEP 484 type hints for C++ types exported to Python 2016-08-04 23:47:07 +02:00
example-numpy-vectorize.ref Adopt PEP 484 type hints for C++ types exported to Python 2016-08-04 23:47:07 +02:00
example-opaque-types.cpp Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-opaque-types.py Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-opaque-types.ref Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-operator-overloading.cpp Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-operator-overloading.py Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-operator-overloading.ref Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-pickling.cpp Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-pickling.py Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-pickling.ref Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-python-types.cpp Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-python-types.py Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-python-types.ref Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-sequences-and-iterators.cpp Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-sequences-and-iterators.py Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-sequences-and-iterators.ref Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-smart-ptr.cpp Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-smart-ptr.py Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-smart-ptr.ref Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-stl-binder-vector.cpp minor namespace change in example 2016-07-19 17:35:09 +02:00
example-stl-binder-vector.py Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-stl-binder-vector.ref Rename examples files, as per #288 2016-07-18 16:43:18 -04:00
example-virtual-functions.cpp Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-virtual-functions.py Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example-virtual-functions.ref Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example.cpp Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
example.h last breaking change: be consistent about the project name 2015-10-15 18:23:56 +02:00
issues.cpp Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
issues.py Implement reference_internal with a keep_alive 2016-08-10 12:08:04 -04:00
issues.ref Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
object.h Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00
run_test.py Improve constructor/destructor tracking 2016-08-11 18:16:04 -04:00