Skip to content

Commit 5ec6c90

Browse files
committed
Fix MSVC warning C26814: "The const variable 'variable' can be computed at compile time. Consider using constexpr.."
1 parent 58f9cfb commit 5ec6c90

File tree

53 files changed

+168
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+168
-168
lines changed

apps/in_hand_scanner/src/icp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pcl::ihs::ICP::findTransformation(const MeshConstPtr& mesh_model,
161161
{
162162
// Check the input
163163
// TODO: Double check the minimum number of points necessary for icp
164-
const std::size_t n_min = 4;
164+
constexpr std::size_t n_min = 4;
165165

166166
if (mesh_model->sizeVertices() < n_min || cloud_data->size() < n_min) {
167167
std::cerr << "ERROR in icp.cpp: Not enough input points!\n";

apps/in_hand_scanner/src/main_window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pcl::ihs::MainWindow::MainWindow(QWidget* parent)
7070
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
7171
ui_->toolBar->insertWidget(ui_->actionHelp, spacer);
7272

73-
const double max = std::numeric_limits<double>::max();
73+
constexpr double max = std::numeric_limits<double>::max();
7474

7575
// In hand scanner
7676
QHBoxLayout* layout = new QHBoxLayout(ui_->placeholder_in_hand_scanner);

apps/in_hand_scanner/src/opengl_viewer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ pcl::ihs::OpenGLViewer::addMesh(const CloudXYZRGBNormalConstPtr& cloud,
484484
const int h = cloud->height;
485485
const int offset_1 = -w;
486486
const int offset_2 = -w - 1;
487-
const int offset_3 = -1;
487+
constexpr int offset_3 = -1;
488488

489489
FaceVertexMeshPtr mesh(new FaceVertexMesh());
490490
mesh->transformation = T;
@@ -1083,7 +1083,7 @@ pcl::ihs::OpenGLViewer::initializeGL()
10831083
void
10841084
pcl::ihs::OpenGLViewer::setupViewport(const int w, const int h)
10851085
{
1086-
const float aspect_ratio = 4. / 3.;
1086+
constexpr float aspect_ratio = 4. / 3.;
10871087

10881088
// Use the biggest possible area of the window to draw to
10891089
// case 1 (w < w_scaled): case 2 (w >= w_scaled):

apps/src/openni_mobile_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ CopyPointCloudToBuffers(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& clou
7979
point.x > bounds_max.x || point.y > bounds_max.y || point.z > bounds_max.z)
8080
continue;
8181

82-
const int conversion_factor = 500;
82+
constexpr int conversion_factor = 500;
8383

8484
cloud_buffers.points[j * 3 + 0] = static_cast<short>(point.x * conversion_factor);
8585
cloud_buffers.points[j * 3 + 1] = static_cast<short>(point.y * conversion_factor);

apps/src/pyramid_surface_matching.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using namespace pcl;
99
#include <iostream>
1010

1111
const Eigen::Vector4f subsampling_leaf_size(0.02f, 0.02f, 0.02f, 0.0f);
12-
const float normal_estimation_search_radius = 0.05f;
12+
constexpr float normal_estimation_search_radius = 0.05f;
1313

1414
void
1515
subsampleAndCalculateNormals(PointCloud<PointXYZ>::Ptr& cloud,

common/include/pcl/common/impl/eigen.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ computeRoots (const Matrix& m, Roots& roots)
8989
computeRoots2 (c2, c1, roots);
9090
else
9191
{
92-
const Scalar s_inv3 = Scalar (1.0 / 3.0);
92+
constexpr Scalar s_inv3 = Scalar(1.0 / 3.0);
9393
const Scalar s_sqrt3 = std::sqrt (Scalar (3.0));
9494
// Construct the parameters used in classifying the roots of the equation
9595
// and in solving the equation for the roots in closed form.

common/include/pcl/point_representation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ namespace pcl
250250
template<typename Key> inline void operator() ()
251251
{
252252
using FieldT = typename pcl::traits::datatype<PointDefault, Key>::type;
253-
const int NrDims = pcl::traits::datatype<PointDefault, Key>::size;
253+
constexpr int NrDims = pcl::traits::datatype<PointDefault, Key>::size;
254254
Helper<Key, FieldT, NrDims>::copyPoint (p1_, p2_, f_idx_);
255255
}
256256

common/include/pcl/register_point_struct.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ namespace pcl
100100
plus (std::remove_const_t<T> &l, const T &r)
101101
{
102102
using type = std::remove_all_extents_t<T>;
103-
static const std::uint32_t count = sizeof (T) / sizeof (type);
103+
constexpr std::uint32_t count = sizeof(T) / sizeof(type);
104104
for (std::uint32_t i = 0; i < count; ++i)
105105
l[i] += r[i];
106106
}
@@ -117,7 +117,7 @@ namespace pcl
117117
plusscalar (T1 &p, const T2 &scalar)
118118
{
119119
using type = std::remove_all_extents_t<T1>;
120-
static const std::uint32_t count = sizeof (T1) / sizeof (type);
120+
constexpr std::uint32_t count = sizeof(T1) / sizeof(type);
121121
for (std::uint32_t i = 0; i < count; ++i)
122122
p[i] += scalar;
123123
}
@@ -134,7 +134,7 @@ namespace pcl
134134
minus (std::remove_const_t<T> &l, const T &r)
135135
{
136136
using type = std::remove_all_extents_t<T>;
137-
static const std::uint32_t count = sizeof (T) / sizeof (type);
137+
constexpr std::uint32_t count = sizeof(T) / sizeof(type);
138138
for (std::uint32_t i = 0; i < count; ++i)
139139
l[i] -= r[i];
140140
}
@@ -151,7 +151,7 @@ namespace pcl
151151
minusscalar (T1 &p, const T2 &scalar)
152152
{
153153
using type = std::remove_all_extents_t<T1>;
154-
static const std::uint32_t count = sizeof (T1) / sizeof (type);
154+
constexpr std::uint32_t count = sizeof(T1) / sizeof(type);
155155
for (std::uint32_t i = 0; i < count; ++i)
156156
p[i] -= scalar;
157157
}
@@ -168,7 +168,7 @@ namespace pcl
168168
mulscalar (T1 &p, const T2 &scalar)
169169
{
170170
using type = std::remove_all_extents_t<T1>;
171-
static const std::uint32_t count = sizeof (T1) / sizeof (type);
171+
constexpr std::uint32_t count = sizeof(T1) / sizeof(type);
172172
for (std::uint32_t i = 0; i < count; ++i)
173173
p[i] *= scalar;
174174
}
@@ -185,7 +185,7 @@ namespace pcl
185185
divscalar (T1 &p, const T2 &scalar)
186186
{
187187
using type = std::remove_all_extents_t<T1>;
188-
static const std::uint32_t count = sizeof (T1) / sizeof (type);
188+
constexpr std::uint32_t count = sizeof (T1) / sizeof (type);
189189
for (std::uint32_t i = 0; i < count; ++i)
190190
p[i] /= scalar;
191191
}
@@ -202,7 +202,7 @@ namespace pcl
202202
divscalar2 (ArrayT &p, const ScalarT &scalar)
203203
{
204204
using type = std::remove_all_extents_t<ArrayT>;
205-
static const std::uint32_t count = sizeof (ArrayT) / sizeof (type);
205+
constexpr std::uint32_t count = sizeof (ArrayT) / sizeof (type);
206206
for (std::uint32_t i = 0; i < count; ++i)
207207
p[i] = scalar / p[i];
208208
}

examples/features/example_difference_of_normals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ int main (int argc, char *argv[])
9999

100100
// Create downsampled point cloud for DoN NN search with large scale
101101
large_cloud_downsampled = PointCloud<PointT>::Ptr(new pcl::PointCloud<PointT>);
102-
const float largedownsample = float (scale2/decimation);
102+
constexpr float largedownsample = float(scale2 / decimation);
103103
sor.setLeafSize (largedownsample, largedownsample, largedownsample);
104104
sor.filter (*large_cloud_downsampled);
105105
std::cout << "Using leaf size of " << largedownsample << " for large scale, " << large_cloud_downsampled->size() << " points" << std::endl;

examples/keypoints/example_sift_z_keypoint_estimation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ main(int, char** argv)
7575
std::cout << "points: " << cloud_xyz->size () <<std::endl;
7676

7777
// Parameters for sift computation
78-
const float min_scale = 0.005f;
79-
const int n_octaves = 6;
80-
const int n_scales_per_octave = 4;
81-
const float min_contrast = 0.005f;
78+
constexpr float min_scale = 0.005f;
79+
constexpr int n_octaves = 6;
80+
constexpr int n_scales_per_octave = 4;
81+
constexpr float min_contrast = 0.005f;
8282

8383
// Estimate the sift interest points using z values from xyz as the Intensity variants
8484
pcl::SIFTKeypoint<pcl::PointXYZ, pcl::PointWithScale> sift;

0 commit comments

Comments
 (0)