📄 io.cpp
字号:
/* Boost examples/io.cpp
* show some exampleso of i/o operators
* thanks to all the people who commented on this point, particularly on
* the Boost mailing-list
*
* Copyright Guillaume Melquiond 2003
* Permission to use, copy, modify, sell, and distribute this software
* is hereby granted without fee provided that the above copyright notice
* appears in all copies and that both that copyright notice and this
* permission notice appear in supporting documentation.
*
* None of the above authors make any representation about the
* suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* $Id: io.cpp,v 1.2 2003/08/22 06:28:08 gmelquio Exp $
*/
#include <boost/numeric/interval.hpp>
#include <boost/io/ios_state.hpp>
#include <cmath>
#include <cassert>
namespace io_std {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "[]";
} else {
return stream << '[' << lower(value) << ',' << upper(value) << ']';
}
}
} // namespace io_std
namespace io_sngl {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "[]";
} else if (singleton(value)) {
return stream << '[' << lower(value) << ']';
} else {
return stream << '[' << lower(value) << ',' << upper(value) << ']';
}
}
} // namespace io_sngl
namespace io_wdth {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "nothing";
} else {
return stream << median(value) << "
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -