Skip to content

Commit

Permalink
Replaced eos::cpp17::optional with std::optional
Browse files Browse the repository at this point in the history
  • Loading branch information
patrikhuber committed Dec 14, 2024
1 parent 5036e01 commit bdc3464
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 1,276 deletions.
4 changes: 2 additions & 2 deletions examples/fit-model-multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "eos/render/texture_extraction.hpp"
#include "eos/render/render.hpp"
#include "eos/render/opencv/draw_utils.hpp"
#include "eos/cpp17/optional.hpp"

#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
Expand All @@ -43,6 +42,7 @@
#include <fstream>
#include <string>
#include <filesystem>
#include <optional>

using namespace eos;
namespace po = boost::program_options;
Expand Down Expand Up @@ -249,7 +249,7 @@ int main(int argc, char *argv[])

std::tie(per_frame_meshes, per_frame_rendering_params) = fitting::fit_shape_and_pose(
morphable_model, blendshapes, per_frame_landmarks, landmark_mapper, image_widths, image_heights, edge_topology,
ibug_contour, model_contour, 5, cpp17::nullopt, 30.0f, cpp17::nullopt, pca_shape_coefficients,
ibug_contour, model_contour, 5, std::nullopt, 30.0f, std::nullopt, pca_shape_coefficients,
blendshape_coefficients, fitted_image_points);

cout << "Final pca shape coefficients: ";
Expand Down
15 changes: 7 additions & 8 deletions include/eos/core/LandmarkMapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
#ifndef EOS_LANDMARKMAPPER_HPP
#define EOS_LANDMARKMAPPER_HPP

#include "eos/cpp17/optional.hpp"

#include "toml.hpp"

#include <stdexcept>
#include <string>
#include <unordered_map>
#include <algorithm>
#include <optional>

namespace eos {
namespace core {
Expand Down Expand Up @@ -114,7 +113,7 @@ class LandmarkMapper
* @param[in] landmark_name A landmark name to convert.
* @return The mapped landmark name if a mapping exists, an empty optional otherwise.
*/
cpp17::optional<std::string> convert(std::string landmark_name) const
std::optional<std::string> convert(std::string landmark_name) const
{
if (landmark_mappings.empty())
{
Expand All @@ -129,7 +128,7 @@ class LandmarkMapper
return converted_landmark->second;
} else
{ // landmark_name does not match the key of any element in the map
return cpp17::nullopt;
return std::nullopt;
}
};

Expand Down Expand Up @@ -170,9 +169,9 @@ class LandmarkMapper
* vertex indices.
* @return An optional int with the vertex index.
*/
inline cpp17::optional<int>
inline std::optional<int>
get_vertex_index(const std::string landmark_name, const core::LandmarkMapper& landmark_mapper,
const cpp17::optional<std::unordered_map<std::string, int>>& landmark_definitions)
const std::optional<std::unordered_map<std::string, int>>& landmark_definitions)
{
const auto converted_name = landmark_mapper.convert(landmark_name);
if (!converted_name)
Expand All @@ -198,11 +197,11 @@ get_vertex_index(const std::string landmark_name, const core::LandmarkMapper& la
vertex_idx = found_vertex_idx->second;
} else
{
return cpp17::nullopt;
return std::nullopt;
}
} else
{
return cpp17::nullopt;
return std::nullopt;
}
}
return vertex_idx;
Expand Down
Loading

0 comments on commit bdc3464

Please sign in to comment.