Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Function template import_class

boost::dll::experimental::import_class

Synopsis

// In header: <boost/dll/import_class.hpp>


template<typename T, typename ... Args> 
  imported_class< T > 
  import_class(const smart_library & lib, std::size_t size, Args... args);

Description

Returns an instance of imported_class which allows to call or import more functions. It takes a copy of the smart_libray, so no added type_aliases will be visible, for the object.

Few compilers do implement an allocating constructor, which allows the construction of the class without knowing the size. That is not portable, so the actual size of the class shall always be provided.

Example:

auto import_class<class type_alias, const std::string&, std::size_t>(lib, "class_name", 20, "param1", 42);

In this example we construct an instance of the class "class_name" with the size 20, which has "type_alias" as an alias, through a constructor which takes a const-ref of std::string and an std::size_t parameter.

xmlonly <link linkend='boost.dll.fs.system_error'>boost::dll::fs::system_error</link> if symbol does not exist or if the DLL/DSO was not loaded. Overload that accepts path also throws std::bad_alloc in case of insufficient memory.

[Note] Note

This function does add the type alias to the boost::dll::experimental::smart_library.

Parameters:

lib

Path to shared library or shared library to load function from.

Template Parameters:

Args

Constructor argument list.

T

Class type or alias

Returns:

class object.

Throws:


PrevUpHomeNext