|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67796 - in trunk: boost/proto libs/proto/test
From: eric_at_[hidden]
Date: 2011-01-08 15:18:43
Author: eric_niebler
Date: 2011-01-08 15:18:42 EST (Sat, 08 Jan 2011)
New Revision: 67796
URL: http://svn.boost.org/trac/boost/changeset/67796
Log:
std::ios_base is not forward-declared in <iosfwd>
Text files modified:
trunk/boost/proto/args.hpp | 29 ++++++++++++++++++++++++++---
trunk/libs/proto/test/deep_copy.cpp | 7 +++++++
2 files changed, 33 insertions(+), 3 deletions(-)
Modified: trunk/boost/proto/args.hpp
==============================================================================
--- trunk/boost/proto/args.hpp (original)
+++ trunk/boost/proto/args.hpp 2011-01-08 15:18:42 EST (Sat, 08 Jan 2011)
@@ -11,7 +11,6 @@
#ifndef BOOST_PROTO_ARGS_HPP_EAN_04_01_2005
#define BOOST_PROTO_ARGS_HPP_EAN_04_01_2005
- #include <iosfwd>
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/preprocessor/cat.hpp>
@@ -22,7 +21,6 @@
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#include <boost/type_traits/is_function.hpp>
#include <boost/type_traits/is_abstract.hpp>
- #include <boost/type_traits/is_base_of.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/void.hpp>
@@ -32,13 +30,38 @@
{
namespace detail
{
+ // All classes derived from std::ios_base have these public nested types,
+ // and are non-copyable. This is an imperfect test, but it's the best we
+ // we can do.
+ template<typename T>
+ yes_type check_is_iostream(
+ typename T::failure *
+ , typename T::Init *
+ , typename T::fmtflags *
+ , typename T::iostate *
+ , typename T::openmode *
+ , typename T::seekdir *
+ );
+
+ template<typename T>
+ no_type check_is_iostream(...);
+
+ template<typename T>
+ struct is_iostream
+ {
+ static bool const value = sizeof(yes_type) == sizeof(check_is_iostream<T>(0,0,0,0,0,0));
+ typedef mpl::bool_<value> type;
+ };
+
/// INTERNAL ONLY
+ // This should be a customization point. And it serves the same purpose
+ // as the is_noncopyable trait in Boost.Foreach.
template<typename T>
struct ref_only
: mpl::or_<
is_function<T>
, is_abstract<T>
- , is_base_of<std::ios_base, T>
+ , is_iostream<T>
>
{};
Modified: trunk/libs/proto/test/deep_copy.cpp
==============================================================================
--- trunk/libs/proto/test/deep_copy.cpp (original)
+++ trunk/libs/proto/test/deep_copy.cpp 2011-01-08 15:18:42 EST (Sat, 08 Jan 2011)
@@ -5,6 +5,8 @@
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#include <iostream>
+#include <boost/utility/addressof.hpp>
#include <boost/proto/core.hpp>
#include <boost/test/unit_test.hpp>
@@ -33,6 +35,11 @@
plus<terminal<void(&)()>::type, terminal<int>::type>::type r4 = deep_copy(t4 + t1);
BOOST_CHECK_EQUAL(42, value(right(r4)));
BOOST_CHECK_EQUAL(&foo, &value(left(r4)));
+
+ terminal<std::ostream &>::type cout_ = {std::cout};
+ shift_left<terminal<std::ostream &>::type, terminal<int>::type>::type r5 = deep_copy(cout_ << t1);
+ BOOST_CHECK_EQUAL(42, value(right(r5)));
+ BOOST_CHECK_EQUAL(boost::addressof(std::cout), boost::addressof(value(left(r5))));
}
using namespace unit_test;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk