1. 14 Dec, 2016 1 commit
    • Jason Rhinelander's avatar
      Change all_of_t/any_of_t to all_of/any_of, add none_of · fa5d05e1
      Jason Rhinelander authored
      This replaces the current `all_of_t<Pred, Ts...>` with `all_of<Ts...>`,
      with previous use of `all_of_t<Pred, Ts...>` becoming
      `all_of<Pred<Ts>...>` (and similarly for `any_of_t`).  It also adds a
      `none_of<Ts...>`, a shortcut for `negation<any_of<Ts...>>`.
      
      This allows `all_of` and `any_of` to be used a bit more flexible, e.g.
      in cases where several predicates need to be tested for the same type
      instead of the same predicate for multiple types.
      
      This commit replaces the implementation with a more efficient version
      for non-MSVC.  For MSVC, this changes the workaround to use the
      built-in, recursive std::conjunction/std::disjunction instead.
      
      This also removes the `count_t` since `any_of_t` and `all_of_t` were the
      only things using it.
      
      This commit also rearranges some of the future std imports to use actual
      `std` implementations for C++14/17 features when under the appropriate
      compiler mode, as we were already doing for a few things (like
      index_sequence).  Most of these aren't saving much (the implementation
      for enable_if_t, for example, is trivial), but I think it makes the
      intention of the code instantly clear.  It also enables MSVC's native
      std::index_sequence support.
      fa5d05e1
  2. 15 Nov, 2016 1 commit
    • Jason Rhinelander's avatar
      Fix stl_bind to support movable, non-copyable value types (#490) · 617fbcfc
      Jason Rhinelander authored
      This commit includes the following changes:
      
      * Don't provide make_copy_constructor for non-copyable container
      
      make_copy_constructor currently fails for various stl containers (e.g.
      std::vector, std::unordered_map, std::deque, etc.) when the container's
      value type (e.g. the "T" or the std::pair<K,T> for a map) is
      non-copyable.  This adds an override that, for types that look like
      containers, also requires that the value_type be copyable.
      
      * stl_bind.h: make bind_{vector,map} work for non-copy-constructible types
      
      Most stl_bind modifiers require copying, so if the type isn't copy
      constructible, we provide a read-only interface instead.
      
      In practice, this means that if the type is non-copyable, it will be,
      for all intents and purposes, read-only from the Python side (but
      currently it simply fails to compile with such a container).
      
      It is still possible for the caller to provide an interface manually
      (by defining methods on the returned class_ object), but this isn't
      something stl_bind can handle because the C++ code to construct values
      is going to be highly dependent on the container value_type.
      
      * stl_bind: copy only for arithmetic value types
      
      For non-primitive types, we may well be copying some complex type, when
      returning by reference is more appropriate.  This commit returns by
      internal reference for all but basic arithmetic types.
      
      * Return by reference whenever possible
      
      Only if we definitely can't--i.e. std::vector<bool>--because v[i]
      returns something that isn't a T& do we copy; for everything else, we
      return by reference.
      
      For the map case, we can always return by reference (at least for the
      default stl map/unordered_map).
      617fbcfc
  3. 06 Sep, 2016 1 commit
  4. 05 Sep, 2016 1 commit
  5. 03 Sep, 2016 1 commit
    • Jason Rhinelander's avatar
      Make test initialization self-registering · 52f4be89
      Jason Rhinelander authored
      Adding or removing tests is a little bit cumbersome currently: the test
      needs to be added to CMakeLists.txt, the init function needs to be
      predeclared in pybind11_tests.cpp, then called in the plugin
      initialization.  While this isn't a big deal for tests that are being
      committed, it's more of a hassle when working on some new feature or
      test code for which I temporarily only care about building and linking
      the test being worked on rather than the entire test suite.
      
      This commit changes tests to self-register their initialization by
      having each test initialize a local object (which stores the
      initialization function in a static variable).  This makes changing the
      set of tests being build easy: one only needs to add or comment out
      test names in tests/CMakeLists.txt.
      
      A couple other minor changes that go along with this:
      
      - test_eigen.cpp is now included in the test list, then removed if eigen
        isn't available.  This lets you disable the eigen tests by commenting
        it out, just like all the other tests, but keeps the build working
        without eigen eigen isn't available.  (Also, if it's commented out, we
        don't even bother looking for and reporting the building with/without
        eigen status message).
      
      - pytest is now invoked with all the built test names (with .cpp changed
        to .py) so that it doesn't try to run tests that weren't built.
      52f4be89
  6. 28 Aug, 2016 1 commit
  7. 19 Aug, 2016 1 commit
    • Dean Moldovan's avatar
      Port tests to pytest · a0c1ccf0
      Dean Moldovan authored
      Use simple asserts and pytest's powerful introspection to make testing
      simpler. This merges the old .py/.ref file pairs into simple .py files
      where the expected values are right next to the code being tested.
      
      This commit does not touch the C++ part of the code and replicates the
      Python tests exactly like the old .ref-file-based approach.
      a0c1ccf0
  8. 19 Jul, 2016 1 commit
  9. 18 Jul, 2016 1 commit
    • Jason Rhinelander's avatar
      Rename examples files, as per #288 · b3f3d79f
      Jason Rhinelander authored
      This renames example files from `exampleN` to `example-description`.
      
      Specifically, the following renaming is applied:
      
      example1 -> example-methods-and-attributes
      example2 -> example-python-types
      example3 -> example-operator-overloading
      example4 -> example-constants-and-functions
      example5 -> example-callbacks (*)
      example6 -> example-sequence-and-iterators
      example7 -> example-buffers
      example8 -> example-custom-ref-counting
      example9 -> example-modules
      example10 -> example-numpy-vectorize
      example11 -> example-arg-keywords-and-defaults
      example12 -> example-virtual-functions
      example13 -> example-keep-alive
      example14 -> example-opaque-types
      example15 -> example-pickling
      example16 -> example-inheritance
      example17 -> example-stl-binders
      example18 -> example-eval
      example19 -> example-custom-exceptions
      
      * the inheritance parts of example5 are moved into example-inheritance
      (previously example16), and the remainder is left as example-callbacks.
      
      This commit also renames the internal variables ("Example1",
      "Example2", "Example4", etc.) into non-numeric names ("ExampleMandA",
      "ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the
      file renaming.
      
      The order of tests is preserved, but this can easily be changed if
      there is some more natural ordering by updating the list in
      examples/CMakeLists.txt.
      b3f3d79f
  10. 30 May, 2016 1 commit
  11. 16 May, 2016 1 commit
  12. 15 May, 2016 2 commits