...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
For the major operations addition, subtraction, intersection
of icl containers and for symmetric
difference inplace operator
s
+= |=,
-=, &=
and ^=
are provided.
For every inplace operator
T& operator o= (T& object, const P& operand)
the icl provides corresponding infix operators.
T operator o (T object, const P& operand){ return object o= operand; } T operator o (const P& operand, T object){ return object o= operand; }
From this implementation of the infix operator
o
the compiler will hopefully use
return value optimization (RVO)
creating no temporary object and performing one copy of the first argument
object
.
Caution | |
---|---|
Compared to the inplace |
Use infix operators only, if
o=
as a copy anyway.
operators o
The time complexity of all infix operators of the icl
is biased by the extra copy of the object
argument. So all infix operators
o
are at least linear
in n =
object.iterative_size()
.
Taking this into account, the complexities of all infix operators can be
determined from the corresponding inplace operators
o=
they depend on.