3

我尝试执行 Project-OSRM 的examle.cpp文件。我做了以下步骤:

  • 如此处所述,从源代码构建 OSRM
  • 在新终端中: cd osrm-backend/example
  • 在终端:cmake ..
  • 在终端: cmake --build 。
  • 在终端: sudo cmake --build 。--目标安装
  • 将地图承包商引擎提取器分区存储、实用程序从/usr/local/include/osrm 移动/ usr/local/include(否则错误地图不在 /usr/local/include 中)
  • 在终端中: g++ -std=c++11 example.cpp -o example

但我得到了错误

‘underlying_type_t’ in namespace ‘std’ does not name a template type
     static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>

有谁知道我做错了什么或出了什么问题以及如何解决这个问题?

错误信息

In file included from /usr/local/include/engine/api/match_parameters.hpp:31:0,
                 from /usr/local/include/osrm/match_parameters.hpp:31,
                 from example.cpp:1:
/usr/local/include/engine/api/route_parameters.hpp: In function ‘bool osrm::engine::api::operator&(osrm::engine::api::RouteParameters::AnnotationsType, osrm::engine::api::RouteParameters::AnnotationsType)’:
/usr/local/include/engine/api/route_parameters.hpp:144:26: error: ‘underlying_type_t’ in namespace ‘std’ does not name a template type
         static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(l
                          ^
/usr/local/include/engine/api/route_parameters.hpp:144:43: error: expected ‘&gt;’ before ‘&lt;’ token
         static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(l
                                           ^
/usr/local/include/engine/api/route_parameters.hpp:144:43: error: expected ‘(’ before ‘&lt;’ token
/usr/local/include/engine/api/route_parameters.hpp:144:43: error: expected primary-expression before ‘&lt;’ token
/usr/local/include/engine/api/route_parameters.hpp:144:76: error: expected primary-expression before ‘&gt;>’ token
    static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(lhs) &
                                                                       ^
/usr/local/include/engine/api/route_parameters.hpp:145:26: error: ‘underlying_type_t’ in namespace ‘std’ does not name a template type
         static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(r
                          ^
/usr/local/include/engine/api/route_parameters.hpp:145:43: error: expected ‘&gt;’ before ‘&lt;’ token
         static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(r
                                           ^
/usr/local/include/engine/api/route_parameters.hpp:145:43: error: expected ‘(’ before ‘&lt;’ token
/usr/local/include/engine/api/route_parameters.hpp:145:43: error: expected primary-expression before ‘&lt;’ token
/usr/local/include/engine/api/route_parameters.hpp:145:76: error: expected primary-expression before ‘&gt;>’ token
    static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(rhs));
                                                                       ^
/usr/local/include/engine/api/route_parameters.hpp:145:84: error: expected ‘)’ before ‘;’ token
    static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(rhs));
                                                                               ^
/usr/local/include/engine/api/route_parameters.hpp:145:84: error: expected ‘)’ before ‘;’ token
/usr/local/include/engine/api/route_parameters.hpp: In function ‘osrm::engine::api::RouteParameters::AnnotationsType osrm::engine::api::operator|(osrm::engine::api::RouteParameters::AnnotationsType, osrm::engine::api::RouteParameters::AnnotationsType)’:
/usr/local/include/engine/api/route_parameters.hpp:152:26: error: ‘underlying_type_t’ in namespace ‘std’ does not name a template type
         static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(l
                          ^
/usr/local/include/engine/api/route_parameters.hpp:152:43: error: expected ‘&gt;’ before ‘&lt;’ token
         static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(l
                                           ^
/usr/local/include/engine/api/route_parameters.hpp:152:43: error: expected ‘(’ before ‘&lt;’ token
/usr/local/include/engine/api/route_parameters.hpp:152:43: error: expected primary-expression before ‘&lt;’ token
/usr/local/include/engine/api/route_parameters.hpp:152:76: error: expected primary-expression before ‘&gt;>’ token
    static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(lhs) |
                                                                       ^
/usr/local/include/engine/api/route_parameters.hpp:153:26: error: ‘underlying_type_t’ in namespace ‘std’ does not name a template type
         static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(r
                          ^
/usr/local/include/engine/api/route_parameters.hpp:153:43: error: expected ‘&gt;’ before ‘&lt;’ token
         static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(r
                                           ^
/usr/local/include/engine/api/route_parameters.hpp:153:43: error: expected ‘(’ before ‘&lt;’ token
/usr/local/include/engine/api/route_parameters.hpp:153:43: error: expected primary-expression before ‘&lt;’ token
/usr/local/include/engine/api/route_parameters.hpp:153:76: error: expected primary-expression before ‘&gt;>’ token
    static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(rhs));
                                                                       ^
/usr/local/include/engine/api/route_parameters.hpp:153:84: error: expected ‘)’ before ‘;’ token
    static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(rhs));
                                                                               ^
/usr/local/include/engine/api/route_parameters.hpp:153:84: error: expected ‘)’ before ‘;’ token
4

2 回答 2

8

underlying_type_t需要 C++14。为了能够使用它传递-std=c++14给您的编译器。

于 2017-05-26T09:15:37.817 回答
0

不要忘记

#include <type_traits>

这个缺失的指令也会导致相同的(令人困惑的)错误消息。

于 2021-06-01T15:15:26.010 回答