在模板类中使用int_的标头 [英] Header for using int_ in template class

查看:82
本文介绍了在模板类中使用int_的标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了C2061语法错误:使用它时标识符'int_'。

是否有标题或者我可以写一些结构来处理它吗?

int x和int_< x>?

的区别是什么

我尝试了什么:



我使用int x但是我出现了一些错误意味着没有在模板类中使用它

I get the C2061 syntax error: identifier 'int_' on using it.
is there a header or can I write some struct to handle that?
what is difference of int x and int_<x>?

What I have tried:

I use int x but I some error appeared that meant don't use that in template class

推荐答案

看起来你使用的代码来自github.com/motonacciu/meta-serialization/blob/master/include/serialize.h [ ^ ]。



如果你查看该文件,你会发现

It looks like you used the code from github.com/motonacciu/meta-serialization/blob/master/include/serialize.h[^].

If you have a look on top of that file, you will find
namespace detail {

	template<std::size_t> struct int_{};

} // end detail namespace 

那个是一个类似于Boost使用的模板(参见解决方案1中的链接)来实现积分常量(参见 MPL参考手册:积分常数 - 1.47.0 [ ^ ])。



如果您使用未修改的文件,它应该使用最近的编译器进行编译(我无法使用VS 2015和2017进行测试,因为我实际上无法访问它们。)

That is a template similar to those used by Boost (see the link from solution 1) to implement an Integral Constant (see The MPL Reference Manual: Integral Constant - 1.47.0[^]).

If you are using the unmodified file it should compile with recent compilers (I can't test it with VS 2015 and 2017 because I have actually no access to those).


你应该知道,那就是:你为什么需要它?你在用什么图书馆?例如,如果您使用 boost MPL ,则相关标头为 boost / mpl / int.hpp ,如上所述通过文档: MPL参考手册:int_ - 1.47.0 [ ^ ]。
You should know, that is: why do you need it? What library are you using? For instance, if you are using boost MPL than the relevant header is boost/mpl/int.hpp, as stated by the documentation: The MPL Reference Manual: int_ - 1.47.0[^].


您不能将它与 int 一起使用,因为它是内置类型,而不是模板。你究竟想要实现什么目标?
You cannot use it with int, as it is a built in type, not a template. What exactly are you trying to achieve?


这篇关于在模板类中使用int_的标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆