Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:49

0001 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
0002 // (C) Copyright 2003-2007 Jonathan Turkanis
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
0005 
0006 // See http://www.boost.org/libs/iostreams for documentation.
0007 
0008 // Contains the definition of the class template access_control, which
0009 // allows the type of inheritance from a provided base class to be specified 
0010 // using a template parameter.
0011 
0012 
0013 #ifndef BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED
0014 #define BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED
0015 
0016 #if defined(_MSC_VER)
0017 # pragma once
0018 #endif              
0019 
0020 #include <boost/iostreams/detail/select.hpp>
0021 #include <boost/mpl/identity.hpp>
0022 #include <boost/type_traits/is_same.hpp>
0023 
0024 namespace boost { namespace iostreams {
0025 
0026 struct protected_ { };  // Represents protected inheritance.
0027 struct public_ { };     // Represents public inheritance.
0028 
0029 
0030 namespace detail {
0031 
0032     // Implements protected inheritance.
0033     template<typename U>
0034     struct prot_ : protected U 
0035     { 
0036         prot_() { }
0037         template<typename V> prot_(V v) : U(v) { }
0038     };
0039 
0040     // Implements public inheritance.
0041     template<typename U> struct pub_ : public U { 
0042         pub_() { }
0043         template<typename V> pub_(V v) : U(v) { }
0044     };
0045 
0046 //
0047 // Used to deduce the base type for the template access_control.
0048 //
0049 template<typename T, typename Access>
0050 struct access_control_base {
0051     typedef int                                 bad_access_specifier;
0052     typedef typename 
0053             iostreams::select<  // Disambiguation for Tru64
0054                 ::boost::is_same<
0055                     Access, protected_
0056                 >,                              prot_<T>,
0057                 ::boost::is_same<
0058                     Access, public_
0059                 >,                              pub_<T>,
0060                 else_,                          bad_access_specifier
0061             >::type                             type;
0062 };
0063 
0064 } // End namespace detail.
0065 
0066 //
0067 // Template name: access_control.
0068 // Description: Allows the type of inheritance from a provided base class
0069 //      to be specified using an int template parameter.
0070 // Template parameters:
0071 //      Base - The class from which to inherit (indirectly.)
0072 //      Access - The type of access desired. Must be one of the 
0073 //          values access_base::prot or access_base::pub.
0074 //
0075 template< typename T, typename Access,
0076           typename Base = // VC6 workaraound (Compiler Error C2516)
0077               typename detail::access_control_base<T, Access>::type >
0078 struct access_control : public Base { 
0079     access_control() { }
0080     template<typename U> explicit access_control(U u) : Base(u) { }
0081 };
0082 
0083 //----------------------------------------------------------------------------//
0084 
0085 } } // End namespaces iostreams, boost.
0086 
0087 #endif // #ifndef BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED