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  namespace detail {
55  /**
56  * \brief int_type::type refers to an integral type that satisfies template parameters
57  * \tparam Bits number of bits in the integral type
58  * \tparam Signed signed or unsigned nature of the type
59  */
60  template <std::size_t Bits, bool Signed = true>
61  struct int_type { using type = void; };
62 
63  /**
64  * \brief helper type to use for `int_type::type`
65  * \see int_type
66  */
67  template <std::size_t Bits, bool Signed = true>
69 
70  template <>
71  struct int_type<8, true> { using type = std::int8_t; };
72  template <>
73  struct int_type<8, false> { using type = std::uint8_t; };
74  template <>
75  struct int_type<16, true> { using type = std::int16_t; };
76  template <>
77  struct int_type<16, false> { using type = std::uint16_t; };
78  template <>
79  struct int_type<32, true> { using type = std::int32_t; };
80  template <>
81  struct int_type<32, false> { using type = std::uint32_t; };
82  template <>
83  struct int_type<64, true> { using type = std::int64_t; };
84  template <>
85  struct int_type<64, false> { using type = std::uint64_t; };
86 
87  /**
88  * \brief number of bits in PCL's index type
89  *
90  * Please use PCL_INDEX_SIZE when building PCL to choose a size best suited for your needs.
91  * PCL 1.12 will come with default 32
92  *
93  * PCL 1.11 has a default size = sizeof(int)
94  */
95  constexpr std::uint8_t index_type_size = PCL_INDEX_SIZE;
96 
97  /**
98  * \brief signed/unsigned nature of PCL's index type
99  * Please use PCL_INDEX_SIGNED when building PCL to choose a type best suited for your needs.
100  * Default: signed
101  */
102  constexpr bool index_type_signed = PCL_INDEX_SIGNED;
103 } // namespace detail
104 
105  /**
106  * \brief Type used for an index in PCL
107  *
108  * Default index_t = int for PCL 1.11, std::int32_t for PCL >= 1.12
109  */
111  static_assert(!std::is_void<index_t>::value, "`index_t` can't have type `void`");
112 
113  /**
114  * \brief Type used for an unsigned index in PCL
115  *
116  * Unsigned index that mirrors the type of the index_t
117  */
119  static_assert(!std::is_signed<uindex_t>::value, "`uindex_t` must be unsigned");
120 
121  /**
122  * \brief Type used for indices in PCL
123  * \todo Remove with C++20
124  */
125  template <typename Allocator = std::allocator<index_t>>
126  using IndicesAllocator = std::vector<index_t, Allocator>;
127 
128  /**
129  * \brief Type used for indices in PCL
130  */
132 } // namespace pcl
133 
pcl::detail::int_type
int_type::type refers to an integral type that satisfies template parameters
Definition: types.h:61
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:73
pcl::detail::int_type< 64, false >::type
std::uint64_t type
Definition: types.h:85
pcl::detail::index_type_size
constexpr std::uint8_t index_type_size
number of bits in PCL's index type
Definition: types.h:95
pcl::detail::int_type< 16, false >::type
std::uint16_t type
Definition: types.h:77
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:110
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:68
pcl::detail::int_type< 16, true >::type
std::int16_t type
Definition: types.h:75
pcl::detail::int_type< 32, true >::type
std::int32_t type
Definition: types.h:79
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:131
pcl::detail::int_type< 32, false >::type
std::uint32_t type
Definition: types.h:81
pcl::detail::int_type< 8, true >::type
std::int8_t type
Definition: types.h:71
pcl::IndicesAllocator
std::vector< index_t, Allocator > IndicesAllocator
Type used for indices in PCL.
Definition: types.h:126
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:102
pcl::detail::int_type< 64, true >::type
std::int64_t type
Definition: types.h:83
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:118
pcl::detail::int_type::type
void type
Definition: types.h:61