Class Template fixed_view

Description
Note
Headers
Reference
Synopsis
Class Template fixed_view
Example

Description

The class template fixed_view is an interface adapter which takes an interface as a template parameter and yeilds a fixed view of the interface: an interface with the same properties as the original interface except that it has no default constructor and cannot be rebound. Fixed views are used as the element_types of the Smart Interface Pointers to help prevent resource leaks and double deletes

Note

In the future it will be possible to use fixed_view in conjunction with const_view to produce an interface whose non-const member functions have been disabled and which cannot be rebound. See Future Directions: Qualifiers.

Headers

<boost/interfaces/fixed_view.hpp>

Reference

Synopsis

namespace boost { namespace interfaces {

template<typename Interface>
class fixed_view {
public:
    template<typename T>
    fixed_view(T& t);

    template<typename Subinterface>
    fixed_view(const Subinterface& other);

    fixed_view(const fixed_view& other);

    template<typename Subinterface>
    fixed_view(const fixed_view<Subinterface>& other);

    operator unspecified-bool-type() const;

    [Member functions from Interface]
};

} } // End namespace boost::interfaces

Class Template fixed_view

Template parameters
Interface-

An interface defined using the Interface Definition Language (IDL).

fixed_view::fixed_view

    fixed_view();

Constructs an unbound fixed_view. Never throws.

    template<typename T>
    fixed_view(T& t)

Constructs a fixed_view bound to the given object. Never throws.

    template<typename Subinterface>
    fixed_view(const Subinterface& other);

Constructs a fixed_view bound to the same object as the given interface. Subinterface must be the same as or a subinterface of the template parameter Interface. Never throws.

    fixed_view(const fixed_view& other);

    template<typename Subinterface>
    fixed_view(const fixed_view<Subinterface>& other);

The first member constructs a copy of the given fixed_view. The second member constructs an instance of fixed_view bound to the same object as the given instance of fixed_view<Subinterface>. Subinterface must be a subinterface of the template parameter Interface. Neither member throws.

fixed_view::operator unspecified-bool-type()

    operator unspecified-bool-type() const;

Returns an unspecified value which, when used in boolean contexts, is equivalent to true. Never throws.

Example

The dereferencing operators of the Smart Interface Pointers templates return references to fixed views to prevent resource leaks and double deletes. If the assignment in the following example were permitted, the dynamically allocated instance of Bar would never be freed, and the stack-allocated instance of Bar would be deleted instead.

namespace idl = boost::interfaces;

idl::shared_ptr<IBar> ptr(new Bar);
Bar b;
*ptr = b; // Error.

Sha'arei Tefila, an Orthodox Shul (Synagogue) in Salt Lake City, Utah Chabad Lubavitch of Utah