]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/doc/reference/pointee.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / python / doc / reference / pointee.qbk
1 [section boost/python/pointee.hpp]
2 [section Introduction]
3 <boost/python/pointee.hpp> introduces a traits metafunction `template pointee<T>` that can be used to extract the "pointed-to" type from the type of a pointer or smart pointer.
4 [endsect]
5 [section Class template `pointee`]
6 `pointee<T>` is used by the [link high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel `class_<...>`] template to deduce the type being held when a pointer or smart pointer type is used as its HeldType argument.
7 ``
8 namespace boost { namespace python
9 {
10 template <class T> struct pointee
11 {
12 typedef T::element_type type;
13 };
14
15 // specialization for pointers
16 template <T> struct pointee<T*>
17 {
18 typedef T type;
19 };
20 }
21 ``
22 [endsect]
23 [section Examples]
24 Given a 3rd-party smart pointer type `smart_pointer<T>`, one might partially specialize `pointee<smart_pointer<T> >` so that it can be used as the HeldType for a class wrapper:
25 ``
26 #include <boost/python/pointee.hpp>
27 #include <boost/python/class.hpp>
28 #include <third_party_lib.hpp>
29
30 namespace boost { namespace python
31 {
32 template <class T> struct pointee<smart_pointer<T> >
33 {
34 typedef T type;
35 };
36 }}
37
38 BOOST_PYTHON_MODULE(pointee_demo)
39 {
40 class_<third_party_class, smart_pointer<third_party_class> >("third_party_class")
41 .def(...)
42 ...
43 ;
44 }
45 ``
46 [endsect]
47 [endsect]