]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpl/doc/src/refmanual/shift_right.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / shift_right.rst
1 .. Metafunctions/Bitwise Operations//shift_right
2
3 shift_right
4 ===========
5
6 Synopsis
7 --------
8
9 .. parsed-literal::
10
11 template<
12 typename T
13 , typename Shift
14 >
15 struct shift_right
16 {
17 typedef |unspecified| type;
18 };
19
20
21
22 Description
23 -----------
24
25 Returns the result of bitwise *shift right* (``>>``) operation on ``T``.
26
27
28 Header
29 ------
30
31 .. parsed-literal::
32
33 #include <boost/mpl/shift_right.hpp>
34 #include <boost/mpl/bitwise.hpp>
35
36
37 Model of
38 --------
39
40 |Numeric Metafunction|
41
42
43 Parameters
44 ----------
45
46 +---------------+-------------------------------+---------------------------+
47 | Parameter | Requirement | Description |
48 +===============+===============================+===========================+
49 | ``T`` | |Integral Constant| | A value to shift. |
50 +---------------+-------------------------------+---------------------------+
51 | ``Shift`` | Unsigned |Integral Constant| | A shift distance. |
52 +---------------+-------------------------------+---------------------------+
53
54 |Note:| |numeric metafunction note| |-- end note|
55
56
57 Expression semantics
58 --------------------
59
60 For arbitrary |Integral Constant| ``c`` and unsigned |Integral Constant| ``shift``:
61
62
63 .. parsed-literal::
64
65 typedef shift_right<c,shift>::type r;
66
67 :Return type:
68 |Integral Constant|.
69
70 :Semantics:
71 Equivalent to
72
73 .. parsed-literal::
74
75 typedef integral_c<
76 c::value_type
77 , ( c::value >> shift::value )
78 > r;
79
80 .. ..........................................................................
81
82 .. parsed-literal::
83
84 typedef shift_right<c,shift> r;
85
86 :Return type:
87 |Integral Constant|.
88
89 :Semantics:
90 Equivalent to
91
92 .. parsed-literal::
93
94 struct r : shift_right<c,shift>::type {};
95
96
97 Complexity
98 ----------
99
100 Amortized constant time.
101
102
103 Example
104 -------
105
106 .. parsed-literal::
107
108 typedef integral_c<unsigned,0> u0;
109 typedef integral_c<unsigned,1> u1;
110 typedef integral_c<unsigned,2> u2;
111 typedef integral_c<unsigned,8> u8;
112
113 BOOST_MPL_ASSERT_RELATION( (shift_right<u0,u0>::value), ==, 0 );
114 BOOST_MPL_ASSERT_RELATION( (shift_right<u1,u0>::value), ==, 1 );
115 BOOST_MPL_ASSERT_RELATION( (shift_right<u1,u1>::value), ==, 0 );
116 BOOST_MPL_ASSERT_RELATION( (shift_right<u2,u1>::value), ==, 1 );
117 BOOST_MPL_ASSERT_RELATION( (shift_right<u8,u1>::value), ==, 4 );
118
119
120 See also
121 --------
122
123 |Bitwise Operations|, |Numeric Metafunction|, |numeric_cast|, |shift_left|, |bitand_|
124
125
126 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
127 Distributed under the Boost Software License, Version 1.0. (See accompanying
128 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)