Point Cloud Library (PCL)  1.11.1-dev
types.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2020-, OpenPerception
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the copyright holder(s) nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 #pragma once
38 
39 /**
40  * \file pcl/types.h
41  *
42  * \brief Defines basic non-point types used by PCL
43  * \ingroup common
44  */
45 
46 #include <pcl/pcl_config.h>
47 #include <pcl/pcl_macros.h>
48 #include <vector>
49 
50 #include <cstdint>
51 
52 namespace pcl
53 {
54  using uint8_t PCL_DEPRECATED(1, 12, "use std::uint8_t instead of pcl::uint8_t") = std::uint8_t;
55  using int8_t PCL_DEPRECATED(1, 12, "use std::int8_t instead of pcl::int8_t") = std::int8_t;
56  using uint16_t PCL_DEPRECATED(1, 12, "use std::uint16_t instead of pcl::uint16_t") = std::uint16_t;
57  using int16_t PCL_DEPRECATED(1, 12, "use std::uint16_t instead of pcl::int16_t") = std::int16_t;
58  using uint32_t PCL_DEPRECATED(1, 12, "use std::uint32_t instead of pcl::uint32_t") = std::uint32_t;
59  using int32_t PCL_DEPRECATED(1, 12, "use std::int32_t instead of pcl::int32_t") = std::int32_t;
60  using uint64_t PCL_DEPRECATED(1, 12, "use std::uint64_t instead of pcl::uint64_t") = std::uint64_t;
61  using int64_t PCL_DEPRECATED(1, 12, "use std::int64_t instead of pcl::int64_t") = std::int64_t;
62  using int_fast16_t PCL_DEPRECATED(1, 12, "use std::int_fast16_t instead of pcl::int_fast16_t") = std::int_fast16_t;
63 
64  namespace detail {
65  /**
66  * \brief int_type::type refers to an integral type that satisfies template parameters
67  * \tparam Bits number of bits in the integral type
68  * \tparam Signed signed or unsigned nature of the type
69  */
70  template <std::size_t Bits, bool Signed = true>
71  struct int_type { using type = void; };
72 
73  /**
74  * \brief helper type to use for `int_type::type`
75  * \see int_type
76  */
77  template <std::size_t Bits, bool Signed = true>
79 
80  template <>
81  struct int_type<8, true> { using type = std::int8_t; };
82  template <>
83  struct int_type<8, false> { using type = std::uint8_t; };
84  template <>
85  struct int_type<16, true> { using type = std::int16_t; };
86  template <>
87  struct int_type<16, false> { using type = std::uint16_t; };
88  template <>
89  struct int_type<32, true> { using type = std::int32_t; };
90  template <>
91  struct int_type<32, false> { using type = std::uint32_t; };
92  template <>
93  struct int_type<64, true> { using type = std::int64_t; };
94  template <>
95  struct int_type<64, false> { using type = std::uint64_t; };
96 
97  /**
98  * \brief number of bits in PCL's index type
99  *
100  * Please use PCL_INDEX_SIZE when building PCL to choose a size best suited for your needs.
101  * PCL 1.12 will come with default 32
102  *
103  * PCL 1.11 has a default size = sizeof(int)
104  */
105  constexpr std::uint8_t index_type_size = PCL_INDEX_SIZE;
106 
107  /**
108  * \brief signed/unsigned nature of PCL's index type
109  * Please use PCL_INDEX_SIGNED when building PCL to choose a type best suited for your needs.
110  * Default: signed
111  */
112  constexpr bool index_type_signed = PCL_INDEX_SIGNED;
113 } // namespace detail
114 
115  /**
116  * \brief Type used for an index in PCL
117  *
118  * Default index_t = int for PCL 1.11, std::int32_t for PCL >= 1.12
119  */
121  static_assert(!std::is_void<index_t>::value, "`index_t` can't have type `void`");
122 
123  /**
124  * \brief Type used for an unsigned index in PCL
125  *
126  * Unsigned index that mirrors the type of the index_t
127  */
129  static_assert(!std::is_signed<uindex_t>::value, "`uindex_t` must be unsigned");
130 
131  /**
132  * \brief Type used for indices in PCL
133  * \todo Remove with C++20
134  */
135  template <typename Allocator = std::allocator<index_t>>
136  using IndicesAllocator = std::vector<index_t, Allocator>;
137 
138  /**
139  * \brief Type used for indices in PCL
140  */
142 } // namespace pcl
143 
pcl::detail::int_type
int_type::type refers to an integral type that satisfies template parameters
Definition: types.h:71
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl
Definition: convolution.h:46
pcl::detail::int_type< 8, false >::type
std::uint8_t type
Definition: types.h:83
pcl::uint32_t
std::uint32_t uint32_t
Definition: types.h:58
pcl::int32_t
std::int32_t int32_t
Definition: types.h:59
pcl::detail::int_type< 64, false >::type
std::uint64_t type
Definition: types.h:95
pcl::detail::index_type_size
constexpr std::uint8_t index_type_size
number of bits in PCL's index type
Definition: types.h:105
pcl::int16_t
std::int16_t int16_t
Definition: types.h:57
pcl::detail::int_type< 16, false >::type
std::uint16_t type
Definition: types.h:87
pcl::uint16_t
std::uint16_t uint16_t
Definition: types.h:56
pcl::index_t
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
Definition: types.h:120
pcl::detail::int_type_t
typename int_type< Bits, Signed >::type int_type_t
helper type to use for int_type::type
Definition: types.h:78
pcl::int_fast16_t
std::int_fast16_t int_fast16_t
Definition: types.h:62
PCL_DEPRECATED
#define PCL_DEPRECATED(Major, Minor, Message)
macro for compatibility across compilers and help remove old deprecated items for the Major....
Definition: pcl_macros.h:156
pcl::int64_t
std::int64_t int64_t
Definition: types.h:61
pcl::detail::int_type< 16, true >::type
std::int16_t type
Definition: types.h:85
pcl::int8_t
std::int8_t int8_t
Definition: types.h:55
pcl::detail::int_type< 32, true >::type
std::int32_t type
Definition: types.h:89
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:141
pcl::detail::int_type< 32, false >::type
std::uint32_t type
Definition: types.h:91
pcl::detail::int_type< 8, true >::type
std::int8_t type
Definition: types.h:81
pcl::IndicesAllocator
std::vector< index_t, Allocator > IndicesAllocator
Type used for indices in PCL.
Definition: types.h:136
pcl::uint8_t
std::uint8_t uint8_t
Definition: types.h:54
pcl::detail::index_type_signed
constexpr bool index_type_signed
signed/unsigned nature of PCL's index type Please use PCL_INDEX_SIGNED when building PCL to choose a ...
Definition: types.h:112
pcl::detail::int_type< 64, true >::type
std::int64_t type
Definition: types.h:93
pcl::uindex_t
detail::int_type_t< detail::index_type_size, false > uindex_t
Type used for an unsigned index in PCL.
Definition: types.h:128
pcl::detail::int_type::type
void type
Definition: types.h:71
pcl::uint64_t
std::uint64_t uint64_t
Definition: types.h:60