命名空间'std'中的错误'underlying_type_t'没有在project-OSRM中的example.cpp中命名模板类型

时间:2017-05-26 08:39:03

标签: c++11 osrm

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

  • 按照here
  • 所述,从源代码构建OSRM 新终端中的
  • :cd osrm-backend / example
  • 在终端:cmake ..
  • 在终端:cmake --build。
  • 在终端:sudo cmake --build。 --target install
  • 移动地图承包商引擎提取器分区存储 util / usr / local / include / osrm / usr / local / include (否则错误映射不在/ usr / local中/包括)
  • 终端中的
  • :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 ‘>’ before ‘<’ token
         static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(l
                                           ^
/usr/local/include/engine/api/route_parameters.hpp:144:43: error: expected ‘(’ before ‘<’ token
/usr/local/include/engine/api/route_parameters.hpp:144:43: error: expected primary-expression before ‘<’ token
/usr/local/include/engine/api/route_parameters.hpp:144:76: error: expected primary-expression before ‘>>’ 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 ‘>’ before ‘<’ token
         static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(r
                                           ^
/usr/local/include/engine/api/route_parameters.hpp:145:43: error: expected ‘(’ before ‘<’ token
/usr/local/include/engine/api/route_parameters.hpp:145:43: error: expected primary-expression before ‘<’ token
/usr/local/include/engine/api/route_parameters.hpp:145:76: error: expected primary-expression 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
    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 ‘>’ before ‘<’ token
         static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(l
                                           ^
/usr/local/include/engine/api/route_parameters.hpp:152:43: error: expected ‘(’ before ‘<’ token
/usr/local/include/engine/api/route_parameters.hpp:152:43: error: expected primary-expression before ‘<’ token
/usr/local/include/engine/api/route_parameters.hpp:152:76: error: expected primary-expression before ‘>>’ 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 ‘>’ before ‘<’ token
         static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(r
                                           ^
/usr/local/include/engine/api/route_parameters.hpp:153:43: error: expected ‘(’ before ‘<’ token
/usr/local/include/engine/api/route_parameters.hpp:153:43: error: expected primary-expression before ‘<’ token
/usr/local/include/engine/api/route_parameters.hpp:153:76: error: expected primary-expression 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
    static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(rhs));
                                                                               ^
/usr/local/include/engine/api/route_parameters.hpp:153:84: error: expected ‘)’ before ‘;’ token

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:0)

别忘了

#include <type_traits>

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