libqi-api  2.4.3.28
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mpl.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2012 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6 
7 #ifndef _QI_MPL_HPP_
8 #define _QI_MPL_HPP_
9 
10 #include <boost/shared_ptr.hpp>
11 #include <boost/weak_ptr.hpp>
12 
13 namespace qi
14 {
15 namespace detail
16 {
17 
18 template <typename T>
19 struct Unwrap
20 {
21  typedef T type;
22  static T* unwrap(T& v)
23  {
24  return &v;
25  }
26 };
27 template <typename T>
28 struct Unwrap<T*>
29 {
30  typedef T type;
31  static T* unwrap(T* v)
32  {
33  return v;
34  }
35 };
36 template <typename T>
37 struct Unwrap<boost::shared_ptr<T> >
38 {
39  typedef T type;
40  static T* unwrap(boost::shared_ptr<T> v)
41  {
42  return v.get();
43  }
44 };
45 template <typename T>
46 struct Unwrap<boost::weak_ptr<T> >
47 {
48  typedef T type;
49  static T* unwrap(boost::weak_ptr<T> v)
50  {
51  return v.lock().get();
52  }
53 };
54 
55 }
56 }
57 
58 #endif
static T * unwrap(T *v)
Definition: mpl.hpp:31
static T * unwrap(T &v)
Definition: mpl.hpp:22