<bdo id='tfh8r'></bdo><ul id='tfh8r'></ul>
    1. <tfoot id='tfh8r'></tfoot>

        <legend id='tfh8r'><style id='tfh8r'><dir id='tfh8r'><q id='tfh8r'></q></dir></style></legend>
      1. <i id='tfh8r'><tr id='tfh8r'><dt id='tfh8r'><q id='tfh8r'><span id='tfh8r'><b id='tfh8r'><form id='tfh8r'><ins id='tfh8r'></ins><ul id='tfh8r'></ul><sub id='tfh8r'></sub></form><legend id='tfh8r'></legend><bdo id='tfh8r'><pre id='tfh8r'><center id='tfh8r'></center></pre></bdo></b><th id='tfh8r'></th></span></q></dt></tr></i><div id='tfh8r'><tfoot id='tfh8r'></tfoot><dl id='tfh8r'><fieldset id='tfh8r'></fieldset></dl></div>
      2. <small id='tfh8r'></small><noframes id='tfh8r'>

        如何获得n嵌套向量的最内部类型?

        How to get the inner most type of a n-nested vector?(如何获得n嵌套向量的最内部类型?)
        1. <small id='uztLQ'></small><noframes id='uztLQ'>

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

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

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

                  <tbody id='uztLQ'></tbody>
                • 本文介绍了如何获得n嵌套向量的最内部类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要获取 n 嵌套向量的内部类型.例如:

                  I need to get the inner type of a n-nested vector. For Example:

                  type a;                          //base_type of a = type
                  std::vector<type> b;             //base_type of b = type
                  std::vector<std::vector<type>> c;//base_type of c = type
                  

                  等等.我尝试使用包装器,但这会导致编译器错误.

                  and so on. I tried using a wrapper, but this results in a compiler error.

                  template<typename T1>
                  struct base_type : T1::value_type { };
                  
                  template<typename T1>
                  struct base_type<std::vector<T1>> {
                      using type = typename base_type<T1>::value_type;
                  };
                  

                  推荐答案

                  你的两个案例都错了.

                  您的基本案例应该是非vector 案例.对于非vector,没有::value_type.你只想要类型:

                  Your base case should be the non-vector case. For a non-vector, there is no ::value_type. You just want the type:

                  template <typename T>
                  struct base_type {
                      using type = T;
                  };
                  

                  对于您的递归情况,base_type 的结果"类型被命名为 type.不是 value_type,所以我们必须在这里使用它:

                  For your recursive case, base_type's "result" type is named type. Not value_type, so we have to use that here:

                  template<typename T>
                  struct base_type<std::vector<T>> {
                      using type = typename base_type<T>::type;
                  };
                  

                  我们可以简化为:

                  template<typename T>
                  struct base_type<std::vector<T>> 
                  : base_type<T>
                  { };
                  

                  这篇关于如何获得n嵌套向量的最内部类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
                  How should a size-limited stl-like container be implemented?(应该如何实现大小受限的 stl 类容器?)
                  Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
                  STL BigInt class implementation(STL BigInt 类实现)
                  Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
                  Move list element to the end in STL(在 STL 中将列表元素移动到末尾)
                  <i id='oyTEl'><tr id='oyTEl'><dt id='oyTEl'><q id='oyTEl'><span id='oyTEl'><b id='oyTEl'><form id='oyTEl'><ins id='oyTEl'></ins><ul id='oyTEl'></ul><sub id='oyTEl'></sub></form><legend id='oyTEl'></legend><bdo id='oyTEl'><pre id='oyTEl'><center id='oyTEl'></center></pre></bdo></b><th id='oyTEl'></th></span></q></dt></tr></i><div id='oyTEl'><tfoot id='oyTEl'></tfoot><dl id='oyTEl'><fieldset id='oyTEl'></fieldset></dl></div>
                  1. <legend id='oyTEl'><style id='oyTEl'><dir id='oyTEl'><q id='oyTEl'></q></dir></style></legend>

                    <tfoot id='oyTEl'></tfoot>
                      <tbody id='oyTEl'></tbody>

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

                        <bdo id='oyTEl'></bdo><ul id='oyTEl'></ul>