Skip to content

Commit 516b014

Browse files
authored
adding Binder limitations documentation section
1 parent 1723c5a commit 516b014

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

documentation/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Contents:
1515
install
1616
basics
1717
config
18+
limitations
1819
examples
1920
debugging
2021
testing

documentation/limitations.rst

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
Binder Limitations
2+
##################
3+
4+
This section lists some of ``binder``'s more prominent limitations.
5+
6+
------------------
7+
External Operators
8+
------------------
9+
10+
Unlike C++, which allows operators to be defined outside of classes and redefined across different namespaces, python requires operators be member functions and thus lacks the ability to choose which overload to use based on context.
11+
In line with this, ``binder`` will only bind (most) C++ operators if they are member functions (i.e. they cannot be defined externally).
12+
13+
These operators include, but are not necessarily limited to:
14+
15+
.. code-block:: console
16+
operator~ (__invert__)
17+
18+
operator+ (__add__)
19+
operator- (__sub__)
20+
operator* (__mul__)
21+
operator/ (__div__)
22+
operator% (__mod__)
23+
24+
operator& (__and__)
25+
operator| (__or__)
26+
operator^ (__xor__)
27+
operator<< (__lshift__)
28+
operator>> (__rshift__)
29+
30+
operator+= (__iadd__)
31+
operator-= (__isub__)
32+
operator*= (__imul__)
33+
operator/= (__idiv__)
34+
operator%= (__imod__)
35+
36+
operator&= (__iand__)
37+
operator|= (__ior__)
38+
operator^= (__ixor__)
39+
operator<<= (__ilshift__)
40+
operator>>= (__irshift__)
41+
42+
operator() (__call__)
43+
operator== (__eq__)
44+
operator!= (__ne__)
45+
operator[] (__getitem__)
46+
operator= (assign)
47+
operator++ (plus_plus)
48+
operator-- (minus_minus)
49+
50+
-----------------
51+
Ignored Operators
52+
-----------------
53+
54+
The following operators will be ignored by binder:
55+
56+
.. code-block:: console
57+
58+
// Logical
59+
&&
60+
||
61+
62+
// Cast to T
63+
explicit operator T()
64+
operator T()
65+
66+
// Misc
67+
,
68+
new
69+
new[]
70+
delete
71+
delete[]
72+
73+
-------------
74+
Miscellaneous
75+
-------------
76+
77+
1. The pre/post increment operators both map to ``plus_plus`, with the pre-increment operator being invoked via ``a.plus_plus()`` and post-increment via ``.plus_plus(0)``; just as the operators are technically defined in C++. The same is true for the pre/post decrement operators, both called ``minus_minus``.
78+
79+
2. User defined literals ``operator"" _foo`` end up being named as ``operator_foo``.
80+
81+
----------
82+
Known Bugs
83+
----------
84+
85+
1. The unary ``operator+`` and unary ``operator-`` currently map to ``__add__`` and ``__sub__`` rather than ``__pos__`` and ``__neg__``.
86+
87+
2. The unary ``operator*`` (dereference operator) will currently map to ``__mul__``.

0 commit comments

Comments
 (0)