Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from boost::tuple to std::tuple #3250

Merged
merged 1 commit into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion io/include/pcl/io/boost.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include <boost/numeric/conversion/cast.hpp>
#include <boost/filesystem.hpp>
#include <boost/cstdint.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/mpl/fold.hpp>
Expand Down
32 changes: 16 additions & 16 deletions io/include/pcl/io/ply/ply_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@

#pragma once

#include <fstream>
#include <iostream>
#include <istream>
#include <memory>
#include <sstream>
#include <string>
#include <vector>

#ifdef BUILD_Maintainer
# if defined __GNUC__
# pragma GCC system_header
Expand All @@ -57,11 +49,19 @@
#endif

#include <pcl/io/boost.h>

#include <pcl/io/ply/ply.h>
#include <pcl/io/ply/io_operators.h>
#include <pcl/pcl_macros.h>

#include <fstream>
#include <iostream>
#include <istream>
#include <memory>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>

namespace pcl
{
namespace io
Expand Down Expand Up @@ -90,7 +90,7 @@ namespace pcl

using begin_element_callback_type = std::function<void ()>;
using end_element_callback_type = std::function<void ()>;
using element_callbacks_type = boost::tuple<begin_element_callback_type, end_element_callback_type>;
using element_callbacks_type = std::tuple<begin_element_callback_type, end_element_callback_type>;
using element_definition_callback_type = std::function<element_callbacks_type (const std::string&, std::size_t)>;

template <typename ScalarType>
Expand Down Expand Up @@ -191,7 +191,7 @@ namespace pcl
using list_property_begin_callback_type = typename list_property_begin_callback_type<SizeType, ScalarType>::type;
using list_property_element_callback_type = typename list_property_element_callback_type<SizeType, ScalarType>::type;
using list_property_end_callback_type = typename list_property_end_callback_type<SizeType, ScalarType>::type;
using type = std::function<boost::tuple<
using type = std::function<std::tuple<
list_property_begin_callback_type,
list_property_element_callback_type,
list_property_end_callback_type
Expand Down Expand Up @@ -515,12 +515,12 @@ inline void pcl::io::ply::ply_parser::parse_list_property_definition (const std:
using list_property_begin_callback_type = typename list_property_begin_callback_type<size_type, scalar_type>::type;
using list_property_element_callback_type = typename list_property_element_callback_type<size_type, scalar_type>::type;
using list_property_end_callback_type = typename list_property_end_callback_type<size_type, scalar_type>::type;
boost::tuple<list_property_begin_callback_type, list_property_element_callback_type, list_property_end_callback_type> list_property_callbacks;
std::tuple<list_property_begin_callback_type, list_property_element_callback_type, list_property_end_callback_type> list_property_callbacks;
if (list_property_definition_callback)
{
list_property_callbacks = list_property_definition_callback (current_element_->name, property_name);
}
if (!boost::get<0> (list_property_callbacks) || !boost::get<1> (list_property_callbacks) || !boost::get<2> (list_property_callbacks))
if (!std::get<0> (list_property_callbacks) || !std::get<1> (list_property_callbacks) || !std::get<2> (list_property_callbacks))
{
if (warning_callback_)
{
Expand All @@ -533,9 +533,9 @@ inline void pcl::io::ply::ply_parser::parse_list_property_definition (const std:
}
current_element_->properties.emplace_back (new list_property<size_type, scalar_type> (
property_name,
boost::get<0> (list_property_callbacks),
boost::get<1> (list_property_callbacks),
boost::get<2> (list_property_callbacks)));
std::get<0> (list_property_callbacks),
std::get<1> (list_property_callbacks),
std::get<2> (list_property_callbacks)));
}

template <typename ScalarType>
Expand Down
6 changes: 4 additions & 2 deletions io/include/pcl/io/ply_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
#include <pcl/io/file_io.h>
#include <pcl/io/ply/ply_parser.h>
#include <pcl/PolygonMesh.h>

#include <sstream>
#include <tuple>

namespace pcl
{
Expand Down Expand Up @@ -284,7 +286,7 @@ namespace pcl
* \param[in] element_name element name
* \param[in] count number of instances
*/
boost::tuple<std::function<void ()>, std::function<void ()> >
std::tuple<std::function<void ()>, std::function<void ()> >
elementDefinitionCallback (const std::string& element_name, std::size_t count);

bool
Expand All @@ -302,7 +304,7 @@ namespace pcl
* \param[in] property_name list property name
*/
template <typename SizeType, typename ScalarType>
boost::tuple<std::function<void (SizeType)>, std::function<void (ScalarType)>, std::function<void ()> >
std::tuple<std::function<void (SizeType)>, std::function<void (ScalarType)>, std::function<void ()> >
listPropertyDefinitionCallback (const std::string& element_name, const std::string& property_name);

/** \brief function called at the beginning of a list property parsing.
Expand Down
2 changes: 1 addition & 1 deletion io/src/ply/ply_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ bool pcl::io::ply::ply_parser::parse (const std::string& filename)
{
element_callbacks = element_definition_callbacks_ (name, count);
}
elements.emplace_back(new element (name, count, boost::get<0>(element_callbacks), boost::get<1>(element_callbacks)));
elements.emplace_back(new element (name, count, std::get<0>(element_callbacks), std::get<1>(element_callbacks)));
current_element_ = elements.back ().get ();
}

Expand Down
21 changes: 11 additions & 10 deletions io/src/ply_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@
#include <map>
#include <sstream>
#include <string>
#include <tuple>

// https://www.boost.org/doc/libs/1_70_0/libs/filesystem/doc/index.htm#Coding-guidelines
#define BOOST_FILESYSTEM_NO_DEPRECATED
#include <boost/filesystem.hpp>

namespace fs = boost::filesystem;

boost::tuple<std::function<void ()>, std::function<void ()> >
std::tuple<std::function<void ()>, std::function<void ()> >
pcl::PLYReader::elementDefinitionCallback (const std::string& element_name, std::size_t count)
{
if (element_name == "vertex")
Expand All @@ -71,14 +72,14 @@ pcl::PLYReader::elementDefinitionCallback (const std::string& element_name, std:
cloud_->point_step = 0;
cloud_->row_step = 0;
vertex_count_ = 0;
return (boost::tuple<std::function<void ()>, std::function<void ()> > (
return (std::tuple<std::function<void ()>, std::function<void ()> > (
[this] { vertexBeginCallback (); },
[this] { vertexEndCallback (); }));
}
if ((element_name == "face") && polygons_)
{
polygons_->reserve (count);
return (boost::tuple<std::function<void ()>, std::function<void ()> > (
return (std::tuple<std::function<void ()>, std::function<void ()> > (
[this] { faceBeginCallback (); },
[this] { faceEndCallback (); }));
}
Expand All @@ -90,7 +91,7 @@ pcl::PLYReader::elementDefinitionCallback (const std::string& element_name, std:
if (element_name == "range_grid")
{
range_grid_->reserve (count);
return (boost::tuple<std::function<void ()>, std::function<void ()> > (
return (std::tuple<std::function<void ()>, std::function<void ()> > (
[this] { rangeGridBeginCallback (); },
[this] { rangeGridEndCallback (); }));
}
Expand Down Expand Up @@ -309,20 +310,20 @@ namespace pcl
}

template <>
boost::tuple<std::function<void (pcl::io::ply::uint8)>, std::function<void (pcl::io::ply::int32)>, std::function<void ()> >
std::tuple<std::function<void (pcl::io::ply::uint8)>, std::function<void (pcl::io::ply::int32)>, std::function<void ()> >
pcl::PLYReader::listPropertyDefinitionCallback (const std::string& element_name, const std::string& property_name)
{
if ((element_name == "range_grid") && (property_name == "vertex_indices" || property_name == "vertex_index"))
{
return boost::tuple<std::function<void (pcl::io::ply::uint8)>, std::function<void (pcl::io::ply::int32)>, std::function<void ()> > (
return std::tuple<std::function<void (pcl::io::ply::uint8)>, std::function<void (pcl::io::ply::int32)>, std::function<void ()> > (
[this] (pcl::io::ply::uint8 size) { rangeGridVertexIndicesBeginCallback (size); },
[this] (pcl::io::ply::int32 vertex_index) { rangeGridVertexIndicesElementCallback (vertex_index); },
[this] { rangeGridVertexIndicesEndCallback (); }
);
}
if ((element_name == "face") && (property_name == "vertex_indices" || property_name == "vertex_index") && polygons_)
{
return boost::tuple<std::function<void (pcl::io::ply::uint8)>, std::function<void (pcl::io::ply::int32)>, std::function<void ()> > (
return std::tuple<std::function<void (pcl::io::ply::uint8)>, std::function<void (pcl::io::ply::int32)>, std::function<void ()> > (
[this] (pcl::io::ply::uint8 size) { faceVertexIndicesBeginCallback (size); },
[this] (pcl::io::ply::int32 vertex_index) { faceVertexIndicesElementCallback (vertex_index); },
[this] { faceVertexIndicesEndCallback (); }
Expand All @@ -341,7 +342,7 @@ namespace pcl
else
cloud_->point_step = static_cast<uint32_t> (std::numeric_limits<uint32_t>::max ());
do_resize_ = true;
return boost::tuple<std::function<void (pcl::io::ply::uint8)>, std::function<void (pcl::io::ply::int32)>, std::function<void ()> > (
return std::tuple<std::function<void (pcl::io::ply::uint8)>, std::function<void (pcl::io::ply::int32)>, std::function<void ()> > (
std::bind (&pcl::PLYReader::vertexListPropertyBeginCallback<pcl::io::ply::uint8>, this, property_name, std::placeholders::_1),
[this] (pcl::io::ply::int32 value) { vertexListPropertyContentCallback<pcl::io::ply::int32> (value); },
[this] { vertexListPropertyEndCallback (); }
Expand All @@ -351,7 +352,7 @@ namespace pcl
}

template <typename SizeType, typename ContentType>
boost::tuple<std::function<void (SizeType)>, std::function<void (ContentType)>, std::function<void ()> >
std::tuple<std::function<void (SizeType)>, std::function<void (ContentType)>, std::function<void ()> >
pcl::PLYReader::listPropertyDefinitionCallback (const std::string& element_name, const std::string& property_name)
{
if (element_name == "vertex")
Expand All @@ -367,7 +368,7 @@ namespace pcl
else
cloud_->point_step = static_cast<uint32_t> (std::numeric_limits<uint32_t>::max ());
do_resize_ = true;
return boost::tuple<std::function<void (SizeType)>, std::function<void (ContentType)>, std::function<void ()> > (
return std::tuple<std::function<void (SizeType)>, std::function<void (ContentType)>, std::function<void ()> > (
std::bind (&pcl::PLYReader::vertexListPropertyBeginCallback<SizeType>, this, property_name, std::placeholders::_1),
[this] (ContentType value) { vertexListPropertyContentCallback (value); },
[this] { vertexListPropertyEndCallback (); }
Expand Down
21 changes: 11 additions & 10 deletions io/tools/ply/ply2obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@
*
*/

#include <pcl/io/boost.h>
#include <pcl/io/ply/ply_parser.h>

#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>

#include <pcl/io/boost.h>
#include <pcl/io/ply/ply_parser.h>
#include <tuple>

/** \class ply_to_obj_converter
* Convert a PLY file, optionally meshed to an OBJ file.
Expand Down Expand Up @@ -81,13 +82,13 @@ class ply_to_obj_converter
void
error_callback (const std::string& filename, std::size_t line_number, const std::string& message);

boost::tuple<std::function<void ()>, std::function<void ()> >
std::tuple<std::function<void ()>, std::function<void ()> >
element_definition_callback (const std::string& element_name, std::size_t count);

template <typename ScalarType> std::function<void (ScalarType)>
scalar_property_definition_callback (const std::string& element_name, const std::string& property_name);

template <typename SizeType, typename ScalarType> boost::tuple<std::function<void (SizeType)>,
template <typename SizeType, typename ScalarType> std::tuple<std::function<void (SizeType)>,
std::function<void (ScalarType)>,
std::function<void ()> >
list_property_definition_callback (const std::string& element_name, const std::string& property_name);
Expand Down Expand Up @@ -155,19 +156,19 @@ ply_to_obj_converter::error_callback (const std::string& filename, std::size_t l
std::cerr << filename << ":" << line_number << ": " << "error: " << message << std::endl;
}

boost::tuple<std::function<void ()>, std::function<void ()> >
std::tuple<std::function<void ()>, std::function<void ()> >
ply_to_obj_converter::element_definition_callback (const std::string& element_name, std::size_t)
{
if (element_name == "vertex")
{
return boost::tuple<std::function<void ()>, std::function<void ()> > (
return std::tuple<std::function<void ()>, std::function<void ()> > (
[this] { vertex_begin (); },
[this] { vertex_end (); }
);
}
if (element_name == "face")
{
return boost::tuple<std::function<void ()>, std::function<void ()> > (
return std::tuple<std::function<void ()>, std::function<void ()> > (
[this] { face_begin (); },
[this] { face_end (); }
);
Expand All @@ -192,11 +193,11 @@ ply_to_obj_converter::scalar_property_definition_callback (const std::string& el
return {};
}

template <> boost::tuple<std::function<void (pcl::io::ply::uint8)>, std::function<void (pcl::io::ply::int32)>, std::function<void ()> >
template <> std::tuple<std::function<void (pcl::io::ply::uint8)>, std::function<void (pcl::io::ply::int32)>, std::function<void ()> >
ply_to_obj_converter::list_property_definition_callback (const std::string& element_name, const std::string& property_name)
{
if ((element_name == "face") && (property_name == "vertex_indices")) {
return boost::tuple<std::function<void (pcl::io::ply::uint8)>, std::function<void (pcl::io::ply::int32)>, std::function<void ()> > (
return std::tuple<std::function<void (pcl::io::ply::uint8)>, std::function<void (pcl::io::ply::int32)>, std::function<void ()> > (
[this] (pcl::io::ply::uint8 p){ face_vertex_indices_begin (p); },
[this] (pcl::io::ply::int32 vertex_index) { face_vertex_indices_element (vertex_index); },
[this] { face_vertex_indices_end (); }
Expand Down
19 changes: 10 additions & 9 deletions io/tools/ply/ply2ply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@
*
*/

#include <pcl/io/boost.h>
#include <pcl/io/ply/ply_parser.h>

#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>

#include <pcl/io/boost.h>
#include <pcl/io/ply/ply_parser.h>
#include <tuple>

/** \class ply_to_ply_converter
* Converts a PLY file with format FORMAT_IN to PLY file with format FORMAT_OUT.
Expand Down Expand Up @@ -95,7 +96,7 @@ class ply_to_ply_converter
void
element_end_callback();

boost::tuple<std::function<void()>, std::function<void()> >
std::tuple<std::function<void()>, std::function<void()> >
element_definition_callback(const std::string& element_name, std::size_t count);

template <typename ScalarType> void
Expand All @@ -113,7 +114,7 @@ class ply_to_ply_converter
template <typename SizeType, typename ScalarType> void
list_property_end_callback();

template <typename SizeType, typename ScalarType> boost::tuple<std::function<void (SizeType)>,
template <typename SizeType, typename ScalarType> std::tuple<std::function<void (SizeType)>,
std::function<void (ScalarType)>,
std::function<void ()> >
list_property_definition_callback(const std::string& element_name, const std::string& property_name);
Expand Down Expand Up @@ -211,10 +212,10 @@ ply_to_ply_converter::element_end_callback()
}
}

boost::tuple<std::function<void()>, std::function<void()> > ply_to_ply_converter::element_definition_callback(const std::string& element_name, std::size_t count)
std::tuple<std::function<void()>, std::function<void()> > ply_to_ply_converter::element_definition_callback(const std::string& element_name, std::size_t count)
{
(*ostream_) << "element " << element_name << " " << count << "\n";
return boost::tuple<std::function<void()>, std::function<void()> >(
return std::tuple<std::function<void()>, std::function<void()> >(
[this] { element_begin_callback (); },
[this] { element_end_callback (); }
);
Expand Down Expand Up @@ -300,13 +301,13 @@ template <typename SizeType, typename ScalarType> void
ply_to_ply_converter::list_property_end_callback() {}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template <typename SizeType, typename ScalarType> boost::tuple<std::function<void (SizeType)>,
template <typename SizeType, typename ScalarType> std::tuple<std::function<void (SizeType)>,
std::function<void (ScalarType)>,
std::function<void ()> >
ply_to_ply_converter::list_property_definition_callback (const std::string&, const std::string& property_name)
{
(*ostream_) << "property list " << pcl::io::ply::type_traits<SizeType>::old_name() << " " << pcl::io::ply::type_traits<ScalarType>::old_name() << " " << property_name << "\n";
return boost::tuple<std::function<void (SizeType)>, std::function<void (ScalarType)>, std::function<void ()> >(
return std::tuple<std::function<void (SizeType)>, std::function<void (ScalarType)>, std::function<void ()> >(
[this] (SizeType size) { list_property_begin_callback<SizeType, ScalarType> (size); },
[this] (ScalarType scalar) { list_property_element_callback<SizeType, ScalarType> (scalar); },
[this] { list_property_end_callback<SizeType, ScalarType> (); }
Expand Down
Loading