]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_traits/doc/is_convertible.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / type_traits / doc / is_convertible.qbk
1 [/
2 Copyright 2007 John Maddock.
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt).
6 ]
7
8 [section:is_convertible is_convertible]
9 template <class From, class To>
10 struct is_convertible : public __tof {};
11
12 __inherit If an imaginary rvalue of type `From` is convertible to type `To` then
13 inherits from __true_type, otherwise inherits from __false_type.
14
15 Type From must not be an incomplete type.
16
17 Type To must not be an incomplete, or function type.
18
19 No types are considered to be convertible to array types or abstract-class types.
20
21 This template can not detect whether a converting-constructor is `public` or not: if
22 type `To` has a `private` converting constructor from type `From` then instantiating
23 `is_convertible<From, To>` will produce a compiler error. For this reason `is_convertible`
24 can not be used to determine whether a type has a `public` copy-constructor or not.
25
26 This template will also produce compiler errors if the conversion is ambiguous,
27 for example:
28
29 struct A {};
30 struct B : A {};
31 struct C : A {};
32 struct D : B, C {};
33 // This produces a compiler error, the conversion is ambiguous:
34 bool const y = boost::is_convertible<D*,A*>::value;
35
36 __std_ref 4 and 8.5.
37
38 [all_compilers]
39
40 __header ` #include <boost/type_traits/is_convertible.hpp>` or ` #include <boost/type_traits.hpp>`
41
42 __examples
43
44 [:`is_convertible<int, double>` inherits from `__true_type`.]
45
46 [:`is_convertible<const int, double>::type` is the type `__true_type`.]
47
48 [:`is_convertible<int* const, int*>::value` is an integral constant
49 expression that evaluates to /true/.]
50
51 [:`is_convertible<int const*, int*>::value` is an integral constant
52 expression that evaluates to /false/: the conversion would require a `const_cast`.]
53
54 [:`is_convertible<int const&, long>::value` is an integral constant
55 expression that evaluates to /true/.]
56
57 [:`is_convertible<int, int>::value` is an integral constant
58 expression that evaluates to /true/.]
59
60 [:`is_convertible<T, T>::value_type` is the type `bool`.]
61
62 [endsect]
63
64