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 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);
template<typename T, typename ... Args> 
  imported_class< T > 
  import_class(const smart_library & lib, std::size_t size, 
               const std::string & alias_name, Args... args);
template<typename T, typename ... Args> 
  imported_class< T > 
  import_class(const smart_library & lib_, const std::string & alias_name, 
               std::size_t size, Args... args);
template<typename T, typename ... Args> 
  imported_class< T > import_class(smart_library && lib, Args... args);
template<typename T, typename ... Args> 
  imported_class< T > 
  import_class(smart_library && lib, const std::string & alias_name, 
               Args... args);
template<typename T, typename ... Args> 
  imported_class< T > 
  import_class(smart_library && lib, std::size_t size, Args... args);
template<typename T, typename ... Args> 
  imported_class< T > 
  import_class(smart_library && lib, std::size_t size, 
               const std::string & alias_name, Args... args);
template<typename T, typename ... Args> 
  imported_class< T > 
  import_class(smart_library && lib, const std::string & alias_name, 
               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.

Parameters:

lib

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

Returns:

class object.

Throws:


PrevUpHomeNext