/usr/share/doc/libbobcat4-dev/man/binopsbase.3.html is in libbobcat-dev 4.08.02-2build1.
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 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | <!DOCTYPE html><html><head>
<meta charset="UTF-8">
<title>binopsbase(3bobcat)</title>
<style type="text/css">
figure {text-align: center;}
img {vertical-align: center;}
.XXfc {margin-left:auto;margin-right:auto;}
.XXtc {text-align: center;}
.XXtl {text-align: left;}
.XXtr {text-align: right;}
.XXvt {vertical-align: top;}
.XXvb {vertical-align: bottom;}
</style>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr/>
<h1 id="title">binopsbase(3bobcat)</h1>
<h2 id="author">Binary Operators<br/>(libbobcat-dev_4.08.02-x.tar.gz)</h2>
<h2 id="date">2005-2017</h2>
<p>
<h2 >NAME</h2>BinopsBase - Class template offering class-type binary operators
<p>
<h2 >SYNOPSIS</h2>
<strong >#include <bobcat/binopsbase></strong><br/>
<p>
<h2 >DESCRIPTION</h2>
Classes may overload binary operators. A class named <em >Derived</em> may
overload binary operators to suit its own needs. It could, e.g., allow two
<em >Derived</em> class objects to be added together, or it could define a
shift-operation given a <em >size_t</em> right-hand side (rhs) argument.
<p>
The available binary operators are *, /, %, +, -, <<, >>, &, |, and ^ (in this
man-page they are generically indicated as the `<em >@</em>' operator). In addition,
overloaded <em >operator<<</em> and <em >operator>></em> for stream insertion and
extraction are frequently defined.
<p>
If a class <em >Derived</em> supports copy and/or move construction and if it offers
a swap member (<em >void Derived::swap(Derived &rhs)</em>), and is publicly derived
from <em >FBB::BinopsBase<Derived></em> then once <em >Derived</em> defines a member
<pre>
void Class::operator@=(Rhs const &rhs) &&
</pre>
defining the compound <em >@</em>-operator for anonymous, temporary <em >Derived</em>
objects and a <em >Rhs</em> type for its right-hand side operand the following
operators are also available:
<pre>
Derived &operator@=(Rhs const &rhs) &
Derived operator@(Derived &&lhs, Rhs const &rhs);
Derived operator@(Derived const &lhs, Rhs const &rhs);
</pre>
<p>
A similar procedure applies to the insertion and extraction
operators. Insertion and extraction operators become available once
<em >BinopsBase<Derived></em> is declared a friend class of <em >Derived</em>. To make
the insertion operator available a private member
<pre>
void Derived::insert(std::ostream &out) const
</pre>
must then also be defined, inserting the calling object into
<em >out</em>. Analogously, to make the extraction operator available a private
member
<pre>
void Derived::extract(std::istream &in)
</pre>
must be defined extrating the calling object from <em >in</em>.
<p>
<h2 >INHERITS FROM</h2>
<p>
--
<p>
<h2 >OVERLOADED OPERATORS</h2>
<p>
For each defined <em >Derived &&operator@=(Rhs const &rhs) &&</em>, defined in
the class <em >Derived</em> the following operators are automatically also available:
<pre>
Derived operator@(Derived &&lhs, Rhs const &rhs);
Derived operator@(Derived const &lhs, Rhs const &rhs);
</pre>
and
<pre>
Derived &operator@=(Rhs const &rhs) &;
</pre>
<p>
The insertion operator becomew available once
<pre>
void Derived::insert(std::ostream &out) const
</pre>
(inserting the calling object into <em >out</em>) has been defined. Analogously,
the extraction operator becomes available after defining a private member
<pre>
void Derived::extract(std::istream &in)
</pre>
(extracting the calling object from <em >in</em>).
<p>
<h2 >FRIEND DECLARATION</h2>
<p>
To make the insertion and/or extraction operators available the class
<em >Derived</em> must also declare
<pre>
friend FBB::BinopsBase<Derived>;
</pre>
<p>
<h2 >EXAMPLE</h2>
<pre >
#include <iostream>
#include <bobcat/binopsbase>
class Demo1: public FBB::BinopsBase<Demo1>
{
friend FBB::BinopsBase<Demo1>; // for insert/extract
public:
void swap(Demo1 &other)
{}
Demo1 &&operator+=(Demo1 const &rhs) &&
{
std::cout << "adding two Demo1 objects\n";
return std::move(*this);
}
// Explicit definitions take precedence over functions templates
// instantiated from definitions in bobcat/binopsbase.
// Demo1 &operator+=(Demo1 const &rhs) &
// {
// std::cout << "adding (self-defined) two Demo1 objects\n";
// return *this;
// }
Demo1 &&operator-=(Demo1 const &rhs) &&
{
std::cout << "subtracting two Demo1 objects\n";
return std::move(*this);
}
Demo1 &&operator<<=(Demo1 const &rhs) &&
{
std::cout << "shiftleft on two Demo1 objects\n";
return std::move(*this);
}
Demo1 &&operator<<=(size_t rhs) &&
{
std::cout << "shiftleft Demo1 object size_t bits\n";
return std::move(*this);
}
void insert(std::ostream &out) const // requires friend
{
out << "inerting a Demo1 object\n";
}
void extract(std::istream &in) // requires friend
{
std::cout << "extracting a Demo1 object\n";
}
};
class Demo2: public FBB::BinopsBase<Demo2>
{
public:
void swap(Demo2 &other)
{}
Demo2 &&operator+=(Demo2 const &rhs) &&
{
std::cout << "adding two Demo2 objects\n";
return std::move(*this);
}
Demo2 &operator+=(Demo2 const &rhs) &
{
std::cout << "adding (self-defined) two Demo2 objects";
return *this;
}
Demo2 &&operator^=(Demo2 const &rhs) &&
{
std::cout << "xor-ing two Demo2 objects\n";
return std::move(*this);
}
Demo2 &&operator|=(Demo2 const &rhs) &&
{
std::cout << "or-ing two Demo2 objects\n";
return std::move(*this);
}
};
int main()
{
Demo1 d1a, d1b;
Demo1 d1c = d1a + d1b;
d1a += d1b;
d1c = Demo1{} + d1b;
std::cout << "Here we are " << d1c << '\n';
std::cin >> d1c;
d1a <<= d1a;
d1a <<= 5;
Demo2 d2a, d2b;
Demo2 d2c = d2a + d2b;
d2a ^= d2b;
d2c = Demo2{} ^ d2b;
d2c = d2c | d2b;
}
</pre>
<p>
<h2 >FILES</h2>
<em >bobcat/binopsbase</em> - defines the binary operator function templates
<p>
<h2 >SEE ALSO</h2>
<strong >bobcat/binops</strong>(3),
<strong >bobcat</strong>(7)
<p>
<h2 >BUGS</h2>
None Reported.
<p>
<h2 >DISTRIBUTION FILES</h2>
<ul>
<li> <em >bobcat_4.08.02-x.dsc</em>: detached signature;
<li> <em >bobcat_4.08.02-x.tar.gz</em>: source archive;
<li> <em >bobcat_4.08.02-x_i386.changes</em>: change log;
<li> <em >libbobcat1_4.08.02-x_*.deb</em>: debian package holding the
libraries;
<li> <em >libbobcat1-dev_4.08.02-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>
</body>
</html>
|