You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
whose maintainer I became in 2002. Since then, C++ has changed significiantly and
31
-
with C++11, the time has come for a complete rewrite and to get rid of some
32
-
*very* old legacy code and work-arounds.
28
+
Overloaded operators for class types typically don't come alone.
29
+
For example, when `x + y` is possible then `x += y` should be, too.
30
+
When `x < y` is possible then `x > y`, `x >= y`, and `x <= y` should be, too.
33
31
34
-
## Rationale
32
+
Implementing large sets of operators, possibly for multiple classes, is both tedious and error-prone.
33
+
However, more often than not, some of these operators can be defined in terms of others.
34
+
For example `x >= y` can frequently be defined as `!(x < y)`.
35
35
36
-
Overloaded operators for class types typically occur in groups.
37
-
If you can write `x + y`, you probably also want to be able to write `x += y`.
38
-
If you can write `x < y`, you also want `x > y`, `x >= y`, and `x <= y`.
39
-
Moreover, unless your class has really surprising behavior, some of these related operators
40
-
can be defined in terms of others (e.g. `x >= y`≡`!(x < y)`).
36
+
Given the implementation of some basic operators, the templates in the Art of C++ / Operators can generate many more operators automatically.
41
37
42
-
Replicating these operators for multiple classes is both tedious and error-prone.
43
-
The Art of C++ / Operators templates help by generating operators for you based on
44
-
other operators you've defined in your class.
45
-
46
-
The generated operators are overloaded to take full advantage of move-aware types
47
-
and are carefully written to allow the compiler to apply important optimizations
48
-
to avoid unneccessary temporary objects. All generated operators are automatically
49
-
marked `noexcept` when the underlying base operations are themself marked as
50
-
`noexcept`. The generated comparison operators are also marked `constexpr`
51
-
(if properly supported by the compiler).
38
+
The generated operators are overloaded to take advantage of movable types, and allow the compiler to avoid unneccessary temporary objects wherever possible.
39
+
All generated operators are `noexcept` when the underlying operations are `noexcept`.
40
+
Generated comparison operators are `constexpr` (when supported by the compiler).
52
41
53
42
## Example
54
43
@@ -949,6 +938,10 @@ Released 2018-02-13
949
938
950
939
* Initial release.
951
940
941
+
## History
942
+
943
+
The Art of C++ / Operators is a modernised C++11 rewrite of the [Boost.Operators](http://www.boost.org/doc/libs/1_66_0/libs/utility/operators.htm) library.
944
+
952
945
## License
953
946
954
947
The Art of C++ is certified [Open Source](http://www.opensource.org/docs/definition.html) software. It may be used for any purpose, including commercial purposes, at absolutely no cost. It is distributed under the terms of the [MIT license](http://www.opensource.org/licenses/mit-license.html) reproduced here.
0 commit comments