mirror of
https://github.com/boostorg/detail.git
synced 2025-07-30 20:37:14 +02:00
Replacing the use of <iomanip> with <boost/detail/iomanip.hpp> across Boost.
On Linux, GNU's libstdc++, which is the default stdlib for icc and clang, cannot parse the <iomanip> header in version 4.5+ (which thankfully neither compiler advises the use of yet), as it's original C++98-friendly implementation has been replaced with a gnu++0x implementation. <boost/detail/iomanip.hpp> is a portable implementation of <iomanip>, providing boost::detail::setfill, boost::detail::setbase, boost::detail::setw, boost::detail::setprecision, boost::detail::setiosflags and boost::detail::resetiosflags. [SVN r68140]
This commit is contained in:
@ -1,13 +1,14 @@
|
|||||||
/*<-============================================================================
|
/*==============================================================================
|
||||||
Copyright (c) 2010 Bryce Lelbach
|
Copyright (c) 2010-2011 Bryce Lelbach
|
||||||
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
============================================================================->*/
|
==============================================================================*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
#include <boost/detail/iomanip.hpp>
|
#include <boost/detail/iomanip.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
@ -18,39 +19,39 @@ int main (void) {
|
|||||||
|
|
||||||
//[setbase_test
|
//[setbase_test
|
||||||
oss << setbase(8) << 8;
|
oss << setbase(8) << 8;
|
||||||
BOOST_TEST(oss.str() == "10");
|
BOOST_TEST_EQ(oss.str(), "10");
|
||||||
|
|
||||||
oss.str("");
|
oss.str("");
|
||||||
oss << setbase(10) << 10;
|
oss << setbase(10) << 10;
|
||||||
BOOST_TEST(oss.str() == "10");
|
BOOST_TEST_EQ(oss.str(), "10");
|
||||||
|
|
||||||
oss.str("");
|
oss.str("");
|
||||||
oss << setbase(16) << 16;
|
oss << setbase(16) << 16;
|
||||||
BOOST_TEST(oss.str() == "10");
|
BOOST_TEST_EQ(oss.str(), "10");
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[setiosflags_test
|
//[setiosflags_test
|
||||||
oss.str("");
|
oss.str("");
|
||||||
oss << setiosflags(std::ios_base::showbase | std::ios_base::hex) << 16;
|
oss << setiosflags(std::ios_base::showbase | std::ios_base::hex) << 16;
|
||||||
BOOST_TEST(oss.str() == "0x10");
|
BOOST_TEST_EQ(oss.str(), "0x10");
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[resetiosflags_test
|
//[resetiosflags_test
|
||||||
oss.str("");
|
oss.str("");
|
||||||
oss << resetiosflags(std::ios_base::showbase | std::ios_base::hex) << 16;
|
oss << resetiosflags(std::ios_base::showbase | std::ios_base::hex) << 16;
|
||||||
BOOST_TEST(oss.str() == "16");
|
BOOST_TEST_EQ(oss.str(), "16");
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[setprecision_test
|
//[setprecision_test
|
||||||
oss.str("");
|
oss.str("");
|
||||||
oss << setprecision(4) << 3.14159;
|
oss << setprecision(4) << 3.14159;
|
||||||
BOOST_TEST(oss.str() == "3.142");
|
BOOST_TEST_EQ(oss.str(), "3.142");
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[setfill_and_setw_test
|
//[setfill_and_setw_test
|
||||||
oss.str("");
|
oss.str("");
|
||||||
oss << setfill('*') << setw(5) << 9;
|
oss << setfill('*') << setw(5) << 9;
|
||||||
BOOST_TEST(oss.str() == "****9");
|
BOOST_TEST_EQ(oss.str(), "****9");
|
||||||
//]
|
//]
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
|
Reference in New Issue
Block a user