CDT++
Causal Dynamical Triangulations in C++
Loading...
Searching...
No Matches
Apply_move.hpp
Go to the documentation of this file.
1/*******************************************************************************
2 Causal Dynamical Triangulations in C++ using CGAL
3
4 Copyright © 2019 Adam Getchell
5 ******************************************************************************/
6
10
11#ifndef CDT_PLUSPLUS_APPLY_MOVE_HPP
12#define CDT_PLUSPLUS_APPLY_MOVE_HPP
13
14#include <spdlog/spdlog.h>
15
16#include <expected>
17#include <string>
18#include <tl/function_ref.hpp>
19
29template <typename ManifoldType,
30 typename ExpectedType = std::expected<ManifoldType, std::string>,
31 typename FunctionType = tl::function_ref<ExpectedType(ManifoldType&)>>
32auto constexpr apply_move(ManifoldType&& t_manifold,
33 FunctionType t_move) noexcept -> decltype(auto)
34{
35 if (auto result = std::invoke(t_move, std::forward<ManifoldType>(t_manifold));
36 result.has_value())
37 {
38 return result;
39 }
40 else // NOLINT
41 {
42 // Log errors
43 spdlog::debug("apply_move called.\n");
44 spdlog::debug("{}", result.error());
45 return result;
46 }
47}
48
49#endif // CDT_PLUSPLUS_APPLY_MOVE_HPP
auto constexpr apply_move(ManifoldType &&t_manifold, FunctionType t_move) noexcept -> decltype(auto)
An applicative function similar to std::apply on a manifold.
Definition: Apply_move.hpp:32