<small id='vpaZk'></small><noframes id='vpaZk'>

    1. <i id='vpaZk'><tr id='vpaZk'><dt id='vpaZk'><q id='vpaZk'><span id='vpaZk'><b id='vpaZk'><form id='vpaZk'><ins id='vpaZk'></ins><ul id='vpaZk'></ul><sub id='vpaZk'></sub></form><legend id='vpaZk'></legend><bdo id='vpaZk'><pre id='vpaZk'><center id='vpaZk'></center></pre></bdo></b><th id='vpaZk'></th></span></q></dt></tr></i><div id='vpaZk'><tfoot id='vpaZk'></tfoot><dl id='vpaZk'><fieldset id='vpaZk'></fieldset></dl></div>

        <tfoot id='vpaZk'></tfoot>
          <bdo id='vpaZk'></bdo><ul id='vpaZk'></ul>
        <legend id='vpaZk'><style id='vpaZk'><dir id='vpaZk'><q id='vpaZk'></q></dir></style></legend>

      1. 宏中使用的模板参数有问题

        Trouble with template parameters used in macros(宏中使用的模板参数有问题)
        <legend id='JtOHv'><style id='JtOHv'><dir id='JtOHv'><q id='JtOHv'></q></dir></style></legend>

                <tbody id='JtOHv'></tbody>
              <i id='JtOHv'><tr id='JtOHv'><dt id='JtOHv'><q id='JtOHv'><span id='JtOHv'><b id='JtOHv'><form id='JtOHv'><ins id='JtOHv'></ins><ul id='JtOHv'></ul><sub id='JtOHv'></sub></form><legend id='JtOHv'></legend><bdo id='JtOHv'><pre id='JtOHv'><center id='JtOHv'></center></pre></bdo></b><th id='JtOHv'></th></span></q></dt></tr></i><div id='JtOHv'><tfoot id='JtOHv'></tfoot><dl id='JtOHv'><fieldset id='JtOHv'></fieldset></dl></div>
              <tfoot id='JtOHv'></tfoot>

              <small id='JtOHv'></small><noframes id='JtOHv'>

              • <bdo id='JtOHv'></bdo><ul id='JtOHv'></ul>

                  本文介绍了宏中使用的模板参数有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试编译以下代码段,在专门用于 std::vector 的行上出现错误,似乎传入的一个参数以某种方式被假定为两个参数.这可能与尖括号有关吗?

                  I'm trying to compile the following piece of code, I get an error on the line which specializes std::vector, it seems the one parameter being passed-in is somehow being assumed to be two parameters. Is it perhaps something to do with angle-brackets?

                  有没有一种特殊的方式/机制可以让这些参数正确地传递给宏?

                  Is there a special way/mechanism where by such parameters can be correctly passed to the macro?

                  #include <vector>
                  
                  template<typename A>
                  struct AClass {};
                  
                  #define specialize_AClass(X)
                  template<> struct AClass<X> { X a; };
                  
                  
                  specialize_AClass(int) //ok
                  
                  specialize_AClass(std::vector<int,std::allocator<int> >) //error
                  
                  int main()
                  {
                     return 0;
                  }
                  

                  我得到的错误如下:

                  1 Line 55: error: macro "specialize_AClass" passed 2 arguments, but takes just 1
                  2 Line 15: error: expected constructor, destructor, or type conversion before 'int'
                  3 compilation terminated due to -Wfatal-errors.
                  

                  链接:http://codepad.org/qIiKsw4l

                  推荐答案

                  template<typename TypeX, typename TypeY>
                  class Test
                  {
                  public:
                      void fun(TypeX x, TypeY y)
                      {
                          std::wcout << _T("Hello") << std::endl;
                          std::wcout << x << std::endl;
                          std::wcout << y << std::endl;
                      }
                  };
                  
                  #define COMMOA ,
                  
                  #define KK(x) x val;
                  
                  void main()
                  {
                      KK(Test<int COMMOA int>);
                      val.fun(12, 13);
                  }
                  

                  我有一个新的方法来解决这个问题.希望能帮到你 :)

                  I have a new way to solve this trouble. hope it can help you :)

                  这篇关于宏中使用的模板参数有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Constructor initialization Vs assignment(构造函数初始化 Vs 赋值)
                  Is a `=default` move constructor equivalent to a member-wise move constructor?(`=default` 移动构造函数是否等同于成员移动构造函数?)
                  Has the new C++11 member initialization feature at declaration made initialization lists obsolete?(声明时新的 C++11 成员初始化功能是否使初始化列表过时了?)
                  Order of constructor call in virtual inheritance(虚继承中构造函数调用的顺序)
                  How to use sfinae for selecting constructors?(如何使用 sfinae 选择构造函数?)
                  Initializing a union with a non-trivial constructor(使用非平凡的构造函数初始化联合)
                • <tfoot id='B4Zf9'></tfoot>
                • <i id='B4Zf9'><tr id='B4Zf9'><dt id='B4Zf9'><q id='B4Zf9'><span id='B4Zf9'><b id='B4Zf9'><form id='B4Zf9'><ins id='B4Zf9'></ins><ul id='B4Zf9'></ul><sub id='B4Zf9'></sub></form><legend id='B4Zf9'></legend><bdo id='B4Zf9'><pre id='B4Zf9'><center id='B4Zf9'></center></pre></bdo></b><th id='B4Zf9'></th></span></q></dt></tr></i><div id='B4Zf9'><tfoot id='B4Zf9'></tfoot><dl id='B4Zf9'><fieldset id='B4Zf9'></fieldset></dl></div>
                    <bdo id='B4Zf9'></bdo><ul id='B4Zf9'></ul>

                      <legend id='B4Zf9'><style id='B4Zf9'><dir id='B4Zf9'><q id='B4Zf9'></q></dir></style></legend>

                              <tbody id='B4Zf9'></tbody>

                          • <small id='B4Zf9'></small><noframes id='B4Zf9'>