...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::dll::experimental::imported_class
// In header: <boost/dll/import_class.hpp> template<typename T> class imported_class { public: // types typedef imported_class< T > base_t; // construct/copy/destruct template<typename ... Args> imported_class(unspecified, const smart_library &, Args...); template<typename ... Args> imported_class(unspecified, const smart_library &, std::size_t, Args...); template<typename ... Args> imported_class(unspecified, smart_library &&, Args...); template<typename ... Args> imported_class(unspecified, smart_library &&, std::size_t, Args...); imported_class() = delete; imported_class(imported_class &) = delete; imported_class(imported_class &&) = default; imported_class & operator=(imported_class &) = delete; imported_class & operator=(imported_class &&) = default; // private member functions template<typename ... Args> unspecified make_data(const smart_library &, Args ...); template<typename ... Args> unspecified make_data(const smart_library &, std::size_t, Args...); // public static functions template<typename ... Args> static imported_class< T > make(smart_library &&, Args...); template<typename ... Args> static imported_class< T > make(smart_library &&, std::size_t, Args...); template<typename ... Args> static imported_class< T > make(const smart_library &, Args...); template<typename ... Args> static imported_class< T > make(const smart_library &, std::size_t, Args...); // public member functions T * get(); bool is_move_constructible(); bool is_move_assignable(); bool is_copy_constructible(); bool is_copy_assignable(); imported_class< T > copy() const; imported_class< T > move(); void copy_assign(const imported_class< T > &) const; void move_assign(imported_class< T > &); explicit operator bool() const; const std::type_info & get_type_info(); template<typename Signature> unspecified call(const std::string &); template<typename Tin, typename Signature, typename = boost::enable_if<detail::unqalified_is_same<T, Tin>> > unspecified call(const std::string &); template<typename Tin, typename T2> unspecified operator->*(unspecified); template<class ... Args> unspecified import(const std::string &); };
This class represents an imported class.
Note | |
---|---|
It must be constructed via boost::dll::import_class(const smart_library& lib, std::size_t, Args...) |
imported_class
public
construct/copy/destructtemplate<typename ... Args> imported_class(unspecified, const smart_library & lib, Args... args);
template<typename ... Args> imported_class(unspecified, const smart_library & lib, std::size_t size, Args... args);
template<typename ... Args> imported_class(unspecified, smart_library && lib, Args... args);
template<typename ... Args> imported_class(unspecified, smart_library && lib, std::size_t size, Args... args);
imported_class() = delete;
imported_class(imported_class &) = delete;
imported_class(imported_class &&) = default;Move constructor.
imported_class & operator=(imported_class &) = delete;
imported_class & operator=(imported_class &&) = default;Move assignmend.
imported_class
public static functionstemplate<typename ... Args> static imported_class< T > make(smart_library && lib, Args... args);
template<typename ... Args> static imported_class< T > make(smart_library && lib, std::size_t size, Args... args);
template<typename ... Args> static imported_class< T > make(const smart_library & lib, Args... args);
template<typename ... Args> static imported_class< T > make(const smart_library & lib, std::size_t size, Args... args);
imported_class
public member functionsT * get();Returns a pointer to the underlying class.
bool is_move_constructible();Check if the imported class is move-constructible.
bool is_move_assignable();Check if the imported class is move-assignable.
bool is_copy_constructible();Check if the imported class is copy-constructible.
bool is_copy_assignable();Check if the imported class is copy-assignable.
imported_class< T > copy() const;Invoke the copy constructor.
Note | |
---|---|
Undefined behaviour if the imported object is not copy constructible. |
imported_class< T > move();Invoke the move constructor.
Note | |
---|---|
Undefined behaviour if the imported object is not move constructible. |
void copy_assign(const imported_class< T > & lhs) const;Invoke the copy assignment.
Note | |
---|---|
Undefined behaviour if the imported object is not copy assignable. |
void move_assign(imported_class< T > & lhs);Invoke the move assignment.
Note | |
---|---|
Undefined behaviour if the imported object is not move assignable. |
explicit operator bool() const;Check if the class is loaded.
const std::type_info & get_type_info();Get a const reference to the std::type_info.
template<typename Signature> unspecified call(const std::string & name);
Call a member function. This returns a proxy to the function. The proxy mechanic mechanic is necessary, so the signaute can be passed.
Example
im_class.call<void(const char*)>("function_name")("MyString");
template<typename Tin, typename Signature, typename = boost::enable_if<detail::unqalified_is_same<T, Tin>> > unspecified call(const std::string & name);
Call a qualified member function, i.e. const and or volatile.
Example
im_class.call<const type_alias, void(const char*)>("function_name")("MyString");
template<typename Tin, typename T2> unspecified operator->*(unspecified mn);Overload of ->* for an imported method.
template<class ... Args> unspecified import(const std::string & name);Import a method of the class.