7 #ifndef MI_BASE_HANDLE_H
8 #define MI_BASE_HANDLE_H
14 #ifdef __cpp_variadic_templates
27 struct Dup_interface_helper {};
111 template <
class Interface>
136 template <
typename I2>
friend class Handle;
150 explicit Handle( Interface* ptr) : m_iptr( ptr) { }
168 : m_iptr( other.m_iptr)
180 template <
class Interface2>
182 : m_iptr( other.
get())
188 #ifdef MI_CXX_FEATURE_RVALUE_REFERENCES
191 : m_iptr( other.m_iptr)
197 template <
class Interface2>
199 : m_iptr( other.m_iptr)
208 Interface* tmp_iptr = m_iptr;
209 m_iptr = other.m_iptr;
210 other.m_iptr = tmp_iptr;
217 Self( other).swap( *
this);
228 template <
class Interface2>
231 Self( other).swap( *
this);
235 #ifdef MI_CXX_FEATURE_RVALUE_REFERENCES
239 if(
this != &other) {
242 m_iptr = other.m_iptr;
249 template <
class Interface2>
254 m_iptr = other.m_iptr;
268 Self( ptr).swap( *
this);
294 Interface*
get()
const {
return m_iptr; }
301 Interface* ptr = m_iptr;
306 #ifdef __cpp_variadic_templates
307 template <
typename... T>
309 Self& emplace(T&&... args)
311 return emplace<Interface>(std::forward<T>(args)...);
319 template <
typename Impl,
typename... T>
320 Self& emplace(T&&... args)
323 m_iptr =
new Impl(std::forward<T>(args)...);
351 template <
class New_
interface>
357 m_iptr->get_interface(
typename New_interface::IID())));
386 return lhs.
get() == rhs;
392 return lhs == rhs.
get();
398 return !( lhs == rhs);
403 return !( lhs == rhs);
408 template <
class Interface1,
class Interface2>
411 return lhs.
get() == rhs.
get();
415 template <
class Interface1,
class Interface2>
418 return !( lhs == rhs);
426 template <
class Interface>
437 template <
class Interface>
443 #ifdef __cpp_variadic_templates
444 template <
typename Impl,
typename... T>
449 inline Handle<Impl> construct_handle(T&&... args)
451 return Handle<Impl>{
new Impl(std::forward<T>(args)...)};
462 #endif // MI_BASE_HANDLE_H