Chris@16: // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) Chris@16: // (C) Copyright 2003-2007 Jonathan Turkanis Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) Chris@16: Chris@16: // See http://www.boost.org/libs/iostreams for documentation. Chris@16: Chris@16: // Contains the definition of the class template access_control, which Chris@16: // allows the type of inheritance from a provided base class to be specified Chris@16: // using a template parameter. Chris@16: Chris@16: Chris@16: #ifndef BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED Chris@16: #define BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1020) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace iostreams { Chris@16: Chris@16: struct protected_ { }; // Represents protected inheritance. Chris@16: struct public_ { }; // Represents public inheritance. Chris@16: Chris@16: Chris@16: namespace detail { Chris@16: Chris@16: // Implements protected inheritance. Chris@16: template Chris@16: struct prot_ : protected U Chris@16: { Chris@16: prot_() { } Chris@16: template prot_(V v) : U(v) { } Chris@16: }; Chris@16: Chris@16: // Implements public inheritance. Chris@16: template struct pub_ : public U { Chris@16: pub_() { } Chris@16: template pub_(V v) : U(v) { } Chris@16: }; Chris@16: Chris@16: // Chris@16: // Used to deduce the base type for the template access_control. Chris@16: // Chris@16: template Chris@16: struct access_control_base { Chris@16: typedef int bad_access_specifier; Chris@16: typedef typename Chris@16: iostreams::select< // Disambiguation for Tru64 Chris@16: ::boost::is_same< Chris@16: Access, protected_ Chris@16: >, prot_, Chris@16: ::boost::is_same< Chris@16: Access, public_ Chris@16: >, pub_, Chris@16: else_, bad_access_specifier Chris@16: >::type type; Chris@16: }; Chris@16: Chris@16: } // End namespace detail. Chris@16: Chris@16: // Chris@16: // Template name: access_control. Chris@16: // Description: Allows the type of inheritance from a provided base class Chris@16: // to be specified using an int template parameter. Chris@16: // Template parameters: Chris@16: // Base - The class from which to inherit (indirectly.) Chris@16: // Access - The type of access desired. Must be one of the Chris@16: // values access_base::prot or access_base::pub. Chris@16: // Chris@16: template< typename T, typename Access, Chris@16: typename Base = // VC6 workaraound (Compiler Error C2516) Chris@16: typename detail::access_control_base::type > Chris@16: struct access_control : public Base { Chris@16: access_control() { } Chris@16: template explicit access_control(U u) : Base(u) { } Chris@16: }; Chris@16: Chris@16: //----------------------------------------------------------------------------// Chris@16: Chris@16: } } // End namespaces iostreams, boost. Chris@16: Chris@16: #endif // #ifndef BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED