error ‘underlying_type_t’ in namespace ‘std’ does not name a template type in example.cpp from project-OSRM
Asked Answered
S

2

5

I try to execute the examle.cpp file of Project-OSRM. I did the following steps:

  • build OSRM from source as described here
  • in new terminal: cd osrm-backend/example
  • in the terminal: cmake ..
  • in the terminal: cmake --build .
  • in the terminal: sudo cmake --build . --target install
  • move the maps contractor, engine, extractor, partition, storage, util from /usr/local/include/osrm to /usr/local/include (else error maps are not in /usr/local/include)
  • in the terminal: g++ -std=c++11 example.cpp -o example

But I get the error

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

Does anyone have a idea what I'm doing wrong or what is going wrong and how to solve this?

Error message

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
Shroyer answered 26/5, 2017 at 8:39 Comment(1)
underlying_type_t requires c++14 like most of the *_t aliases.Epiphora
J
11

underlying_type_t requires C++14. To be able to use it pass -std=c++14 to your compiler.

Jenson answered 26/5, 2017 at 9:15 Comment(0)
D
2

Don't forget to

#include <type_traits>

This missing directive also lead to the same (confusing) error message.

Dionysian answered 1/6, 2021 at 15:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.