首页 \ 问答 \ 命名空间'std'中的错误'underlying_type_t'没有在project-OSRM中的example.cpp中命名模板类型(error ‘underlying_type_t’ in namespace ‘std’ does not name a template type in example.cpp from project-OSRM)

命名空间'std'中的错误'underlying_type_t'没有在project-OSRM中的example.cpp中命名模板类型(error ‘underlying_type_t’ in namespace ‘std’ does not name a template type in example.cpp from project-OSRM)

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

  • 如此处所述,从源代码构建OSRM
  • 在新终端:cd osrm-backend / example
  • 在终端:cmake ..
  • 在终端:cmake --build。
  • 在终端:sudo cmake --build。 --target install
  • 将地图承包商引擎提取器分区存储util/ 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 ‘>’ 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

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

原文:https://stackoverflow.com/questions/44197178
更新时间:2023-06-22 14:06

最满意答案

是的,这不行。 桌面会话中的每个唯一窗口都必须具有唯一的Windows“类名”,该字符串传递给RegisterClassEx()winapi函数并在CreateWindowEx()中使用。 Winforms自动生成这些名称,因此它有责任确保它生成的名称不会与其他进程和appdomains中的窗口名称冲突。 这就是为什么你看到这些奇怪的名字,最重要的部分是你的例子中的最后一点39cfeeb,AppDomain.GetHashCode()返回的值。 您无法从外部进程检索该哈希代码。

您需要一种根本不同的方法,而不依赖于易于获得的类名。 查看Managed Spy代码 ,它支持在外部Winforms进程上使用Reflection。 隔离它使用的DLL注入代码技术,这样你就可以在自己的代码中自己使用它来完成一些工作。

这也是你从过程中获得.NET类名的唯一方法,在使用UI自动化时你从未真正关心过这个问题。


Yes, this can't work. Every unique window in a desktop session must have a unique Windows "class name", the string passed to the RegisterClassEx() winapi function and used in CreateWindowEx(). Winforms auto-generates those names so it has the burden to ensure that the names it generates don't collide with names of windows in other processes and appdomains. Which is why you see these bizarro names, the most important part is the last bit, 39cfeeb in your example, the value returned by AppDomain.GetHashCode(). You cannot retrieve that hash code from an external process.

You'll need a fundamentally different approach that doesn't rely on the easily obtainable class name. Look at the Managed Spy code, it supports using Reflection on an external Winforms process. Isolating the DLL injection code technique it uses so you can use this yourself in your own code takes some work.

Also the only way you'll ever get the .NET class name out of the process, something you otherwise never really care about when using UI automation.

相关问答

更多
  • 窗口句柄保证是有效的,只要窗口存在就不会被重用。 它像自然界中的索引一样,全局有效,并且通常表现得更像是一个全局ID,而不像内核句柄(它只在一个进程和指针中有效)。 一旦窗口关闭,窗口句柄可能会被重用,现在指向另一个窗口。 但不明显的是,如果Form的生命周期和基础窗口window的寿命相同。 我隐约记得,在Delphi的VCL(这是Windows.Forms的精神前驱)中,某些属性更改在后台重新创建了窗口。 Control.RecreatingHandle属性的存在似乎表明底层窗口的生命周期的确可能比.n ...
  • 根据当前的WebDriver API规范 : 6.3在Windows上迭代 getWindowHandles 包含此会话中每个打开窗口的窗口句柄的数组。 此返回字符串数组必须包含与浏览器会话关联的每个窗口的句柄,而不包含其他窗口。 对于每个返回的窗口句柄,javascript表达式“window.top.closed”(或等效的)在执行命令时必须求值为false。 未定义数组元素的排序,但可以通过迭代每个顶级浏览器窗口并在迭代下一个顶级浏览器窗口的选项卡之前返回该窗口内的选项卡来确定。 简而言之,不 - 没 ...
  • My.Forms.Form1 aka的实例。 Form1在每个帖子中都是不同的。 您需要一个正确实例的句柄。 将一个按钮拖放到Form1并添加以下代码: Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Threading.Tasks.Task.Factory.StartNew(Sub() Class1.Wrong()) ...
  • 我所知道的最好的计数器是Taskmgr.exe。 查看+选择列并选中“用户对象”,“处理计数”和“GDI对象”。 通用诊断是您泄漏句柄并消耗了10,000个句柄。 请注意.NET 2.0 SP1和.NET 3.5的Graphics.CopyFromScreen()中的句柄泄漏错误,修复于3.5 SP1。 The best counter I know is Taskmgr.exe. View + Select Columns and check "User objects", "Handle count" ...
  • 这可以返回主窗口句柄。 System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle 据我所知,没有办法得到一个具体的窗口,因为它只不过是Form对象。 但Form类有一个属性Handle 。 您可以将其作为参数传递给dll方法调用。 This can return the main window handle. System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle ...
  • HWND hWnd = GetSafeHwnd(); 应该做的伎俩,但CDialog本身派生自CWnd所以m_hWnd也可以在CDialog内部访问 HWND hWnd = GetSafeHwnd(); Should do the trick, but CDialog is itself derived from CWnd so m_hWnd would be accessable inside CDialog too
  • 我使用一些函数(如“ GetProcessesByName ”)来获取主窗口的句柄,使用“ EnumChildWindows ”来获取子窗口的句柄。请参阅下面的源代码, using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Wi ...
  • 是的,这不行。 桌面会话中的每个唯一窗口都必须具有唯一的Windows“类名”,该字符串传递给RegisterClassEx()winapi函数并在CreateWindowEx()中使用。 Winforms自动生成这些名称,因此它有责任确保它生成的名称不会与其他进程和appdomains中的窗口名称冲突。 这就是为什么你看到这些奇怪的名字,最重要的部分是你的例子中的最后一点39cfeeb,AppDomain.GetHashCode()返回的值。 您无法从外部进程检索该哈希代码。 您需要一种根本不同的方法,而 ...
  • 最简单的解决方案是JNA 。 FindWindow示例: WinDef.HWND hWnd = User32.INSTANCE.FindWindow("className", "windowName"); The easiest solution is JNA. FindWindow example: WinDef.HWND hWnd = User32.INSTANCE.FindWindow("className", "windowName");

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)