// (C) Copyright David Abrahams 2004. // (C) Copyright Jonathan Turkanis 2004. // 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. #ifndef BOOST_IOSTREAMS_DEFAULT_ETRACTABLE_HPP_INCLUDED #define BOOST_IOSTREAMS_DEFAULT_ETRACTABLE_HPP_INCLUDED #include #include #include #include namespace boost { namespace io { // This namespace ensures that ADL doesn't mess things up. namespace default_extractable_ { // a type returned from operator++ when no increment is found in the // type's own namespace struct tag { }; // any soaks up implicit conversions and makes the following // operator<< less-preferred than any other such operator that // might be found via ADL. struct any { template any(T const&); }; // This is a last-resort operator>> for when none other is found template tag operator>>(std::basic_istream&, const any&); // two check overloads help us identify which operator<< was picked char (& check(tag) )[2]; template char check(std::basic_istream&); template struct impl { static typename add_reference< typename remove_cv::type >::type t; static std::basic_istream& in; BOOST_STATIC_CONSTANT( bool, value = sizeof(default_extractable_::check(in >> t)) == 1 ); }; } // End namespace default_extractable_. template< class T, typename Ch = char, typename Tr = std::char_traits > struct is_default_extractable : mpl::bool_< ::boost::io::default_extractable_::impl::value > { }; } } // End namespace boost::io. #endif // BOOST_IOSTREAMS_DEFAULT_ETRACTABLE_HPP_INCLUDED