1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
2 // (C) Copyright 2003-2007 Jonathan Turkanis
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
6 // See http://www.boost.org/libs/iostreams for documentation.
8 // Contains the definition of the class template access_control, which
9 // allows the type of inheritance from a provided base class to be specified
10 // using a template parameter.
13 #ifndef BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED
14 #define BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED
20 #include <boost/iostreams/detail/select.hpp>
21 #include <boost/mpl/identity.hpp>
22 #include <boost/type_traits/is_same.hpp>
24 namespace boost { namespace iostreams {
26 struct protected_ { }; // Represents protected inheritance.
27 struct public_ { }; // Represents public inheritance.
32 // Implements protected inheritance.
34 struct prot_ : protected U
37 template<typename V> prot_(V v) : U(v) { }
40 // Implements public inheritance.
41 template<typename U> struct pub_ : public U {
43 template<typename V> pub_(V v) : U(v) { }
47 // Used to deduce the base type for the template access_control.
49 template<typename T, typename Access>
50 struct access_control_base {
51 typedef int bad_access_specifier;
53 iostreams::select< // Disambiguation for Tru64
60 else_, bad_access_specifier
64 } // End namespace detail.
67 // Template name: access_control.
68 // Description: Allows the type of inheritance from a provided base class
69 // to be specified using an int template parameter.
70 // Template parameters:
71 // Base - The class from which to inherit (indirectly.)
72 // Access - The type of access desired. Must be one of the
73 // values access_base::prot or access_base::pub.
75 template< typename T, typename Access,
76 typename Base = // VC6 workaraound (Compiler Error C2516)
77 typename detail::access_control_base<T, Access>::type >
78 struct access_control : public Base {
80 template<typename U> explicit access_control(U u) : Base(u) { }
83 //----------------------------------------------------------------------------//
85 } } // End namespaces iostreams, boost.
87 #endif // #ifndef BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED