/usr/share/doc/libbobcat2-dev/man/binops.3.html is in libbobcat-dev 2.20.01-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | <html><head>
<title>binops</title>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr>
<h1>binops</h1>
<h2>libbobcat1-dev_2.20.01-x.tar.gz</h2>
<h2>2005-2011</h2>
<html><head>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr>
<h1></h1>
<html><head>
<title>binops(3bobcat)</title>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr>
<h1>binops(3bobcat)</h1>
<h2>libbobcat1-dev_2.20.01-x.tar.gz Binary Operators</h2>
<h2>2005-2011</h2>
<p>
<h2>NAME</h2>binops - Template functions for class-type binary operators
<p>
<h2>SYNOPSIS</h2>
<strong>#include <utility></strong><br>
<strong>#include <bobcat/typetrait></strong><br>
<strong>#include <bobcat/binops></strong><br>
<p>
<h2>DESCRIPTION</h2>
Classes can overload binary operators. A class named <em>Class</em> may
overload these binary operators to suit its own needs, allowing, e.g., two
<em>Class</em> type objects to be added after overloading <em>operator+</em>. Operators
for the binary operators *, /, %, +, -, <<, >>, &, |, and ^ (in this man-page
they are generically indicated as the `<em>@</em>' operator) can be overloaded by
defining the <em>operator@</em> function.
<p>
If a class supports copy construction and if it offers binary assignment
operators (i.e., it offers members of the form <em>operator@=</em>), then the
matching binary operators can all be implemented identically. The
<em>move-aware</em> <em>Class &operator@(Class &&lhs, Class const &rhs)</em> is easily
implemented in terms of <em>operator@=</em> (note that the class itself doesn't
have to be `move-aware' to define this function). The move-aware binary
operator one requires a one line implementation, and as its
implementation never changes it could safely be defined <em>inline</em>:
<pre>
Class operator@(Class &&lhs, Class const &rhs)
{
return std::move(lhs @= rhs);
}
</pre>
The traditional binary operator can be implemented using its standard
form:
<pre>
Class operator@(Class const &lhs, Class const &rhs)
{
Class tmp(lhs);
tmp @= rhs;
return tmp;
}
</pre>
The implementation in <em>bobcat/binops</em> is slightly more complex as it
allows from lhs or rhs promotions.
<p>
As the binary operators can all be implemented alike their definitions are
perfectly suited for templates: A class offering a particular <em>operator@=</em>
then automatically also offers the matching binary operators after including
<em>bobcat/binops</em>. Since the binary function templates are not instantiated
until used their definitions can be processed by the compiler even if a class
implements only a subset of the available binary assignment operators.
<p>
<h2>NAMESPACE</h2>
<p>
The binary operator functions templates in <em>bobcat/binops</em> are <em>not</em>
implemented in a particular namespace. This allows sources to include
<em>bobcat/binops</em> in multiple namespaces.
<p>
If <em>bobcat/binops</em> is to be used in multiple namespaces then the include
safeguard (using the identifier <em>INCLUDED_BOBCAT_BINOPS_</em>) must be
suppressed between inclusions of <em>bobcat/binops</em> in different
namespaces.
<p>
E.g., to make the binary operator function templates available in a source
file using the <em>namespace FBB</em> and in a source file using the default
namespace the following scheme can be used:
<pre>
#include <utility> // ensure std::move is available
#include <bobcat/typetrait> // required by binops
namespace MY_NAMESPACE
{
#include <bobcat/binops> // binary operators available in MY_NAMESPACE
}
#undef INCLUDED_BOBCAT_BINOPS_ // suppress the include guard
#include <bobcat/binops> // read binops again so the binary
// operators can be used in the
// default namespace as well
</pre>
<p>
<h2>INHERITS FROM</h2>
-
<p>
<h2>OVERLOADED OPERATORS</h2>
The function templates in <em>bobcat/binops</em> implement all arithmetic
binary operators, both move-aware and the traditional binary operators,
expecting constant lvalue references. They can be used if the matching binary
assignment operators were implemented in the classes for which the templates
must be instantiated. The following operators are available:
<p>
Move-aware operators, using temporary objects for its left-hand side operands:
<ul>
<li> <strong>Class operator*(Class &&lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator/(Class &&lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator%(Class &&lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator+(Class &&lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator-(Class &&lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator<<(Class &&lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator>>(Class &&lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator&(Class &&lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator|(Class &&lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator^(Class &&lhs, Class const &rhs)</strong>:<br>
</ul>
<p>
`Traditional' operators, using lvalue references to constant objects
for its left-hand side operands:
<ul>
<li> <strong>Class operator*(Class const &lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator/(Class const &lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator%(Class const &lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator+(Class const &lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator-(Class const &lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator<<(Class const &lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator>>(Class const &lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator&(Class const &lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator|(Class const &lhs, Class const &rhs)</strong>:<br>
<li> <strong>Class operator^(Class const &lhs, Class const &rhs)</strong>:<br>
</ul>
The latter group of operators also support promotions.
<p>
<h2>EXAMPLE</h2>
<pre>
#include <iostream>
#include <utility>
#include "../../typetrait/typetrait"
#include "../binops"
class Demo
{
friend std::ostream &operator<<(std::ostream &out, Demo const &demo);
int d_value;
public:
Demo(int value = 0)
:
d_value(value)
{}
Demo(Demo const &other)
:
d_value(other.d_value)
{
std::cout << "Demo CC called\n";
}
Demo &operator+=(Demo const &rhs)
{
d_value += rhs.d_value;
return *this;
}
};
std::ostream &operator<<(std::ostream &out, Demo const &demo)
{
return out << demo.d_value;
}
using namespace std;
int main()
{
Demo four(4);
Demo five(5);
cout << four + five << '\n' <<
four + 5 << '\n' <<
4 + five << '\n';
}
</pre>
<p>
<h2>FILES</h2>
<em>bobcat/binops</em> - defines the binary operator function templates
<p>
<h2>SEE ALSO</h2>
<strong>bobcat</strong>(7)
<p>
<h2>BUGS</h2>
<ul>
<li> The header files <em>utility</em>, defining <em>std::move</em>, and
<em>bobcat/typetrait</em> are required by, but are not included by
<em>bobcat/binops</em>. This was a design decision, see the <strong>NAMESPACE</strong>
section.
</ul>
<p>
<h2>DISTRIBUTION FILES</h2>
<ul>
<li> <em>bobcat_2.20.01-x.dsc</em>: detached signature;
<li> <em>bobcat_2.20.01-x.tar.gz</em>: source archive;
<li> <em>bobcat_2.20.01-x_i386.changes</em>: change log;
<li> <em>libbobcat1_2.20.01-x_*.deb</em>: debian package holding the
libraries;
<li> <em>libbobcat1-dev_2.20.01-x_*.deb</em>: debian package holding the
libraries, headers and manual pages;
<li> <em>http://sourceforge.net/projects/bobcat</em>: public archive location;
</ul>
<p>
<h2>BOBCAT</h2>
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.
<p>
<h2>COPYRIGHT</h2>
This is free software, distributed under the terms of the
GNU General Public License (GPL).
<p>
<h2>AUTHOR</h2>
Frank B. Brokken (<strong>f.b.brokken@rug.nl</strong>).
<p>
|