Function Template extract

Description
Headers
Reference
Synopsis
Class bad_extract
Function Template extract

Description

The function template extract allows the object bound to an interface instance to be retrieved in a type-safe manner.

Headers

<boost/interfaces/extract.hpp>

Reference

Synopsis

namespace boost { namespace interfaces {

class bad_extract : public std::bad_cast {
public:
    const char* what() const throw();
};

template<typename T, typename Interface>
T& extract(const Interface& i); // throw(bad_extract) 

} } // End namespace boost::interfaces

Class Template bad_extract

Description

The class bad_extract is an exception type thrown by extract to indicate that an extraction has failed.

bad_extract::what

    const char* what() const throw();

Returns an implementation-defined string identifying this exception as an instance of bad_extract.

Function Template extract

template<typename T, typename Interface>
T& extract(const Interface& i);
Template Parameters
Interface-

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

T-

A class implementing Interface.

Retrieves the object bound to i as a reference to T.

The extraction will succeed only if i is bound to an object and if the static type of the object, at the point it was bound to i, is the same as or derived from T. If the extraction cannot succeed, extract throws an exception of type bad_extract.

extract is implemented using exception handling, and is therefore a relatively expensive operation.


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