binary.cpp
Go to the documentation of this file.
#include <itpp/base/binary.h>
#include <iostream>
namespace itpp
{
std::ostream &operator<<(std::ostream &output, const bin &inbin)
{
output << static_cast<int>(inbin);
return output;
}
std::istream &operator>>(std::istream &input, bin &outbin)
{
int tmp;
input >> tmp;
it_assert((tmp == 0) || (tmp == 1),
"bin::operator>>(): input value must be 0 or 1");
outbin = tmp;
return input;
}
} // namespace itpp
binary.h
Binary class definition.
itpp::bin
Binary arithmetic (boolean) class.
Definition: binary.h:57
it_assert
#define it_assert(t, s)
Abort if t is not true.
Definition: itassert.h:94
itpp
itpp namespace
Definition: itmex.h:37
itpp::operator<<
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
Definition: binary.cpp:36
itpp::operator>>
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.
Definition: binary.cpp:42

Generated on Tue Aug 17 2021 10:59:15 for IT++ by Doxygen 1.9.1