title: While using templates: error: no matching constructor for initialization of
body: <p>There is a namespace with <code>detail::RayIntersectorHits</code>:</p>
  <pre class="lang-cpp prettyprint-override"><code>namespace detail {
  
      template&lt;typename AVertexType, typename AIndexedFaceType, typename ATreeType, typename AVectorType&gt;
      struct RayIntersector {
          using VertexType        = AVertexType;
          using IndexedFaceType   = AIndexedFaceType;
          using TreeType          = ATreeType;
          using VectorType        = AVectorType;
  
          const std::vector&lt;VertexType&gt;       &amp;vertices;
          const std::vector&lt;IndexedFaceType&gt;  &amp;faces;
          const TreeType                      &amp;tree;
  
          const VectorType                     origin;
          const VectorType                     dir;
          const VectorType                     invdir;
      };
  
      template&lt;typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType&gt;
      struct RayIntersectorHits : RayIntersector&lt;VertexType, IndexedFaceType, TreeType, VectorType&gt; {
          std::vector&lt;igl::Hit&gt;                hits;
      }
  
  }
  </code></pre>
  <p>I'm using <code>detail::RayIntersectorHits</code> this like this:</p>
  <pre class="lang-cpp prettyprint-override"><code>template&lt;typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType&gt;
  inline bool intersect_ray_all_hits(/* input agrs */)
  {
      auto ray_intersector = detail::RayIntersectorHits&lt;VertexType, IndexedFaceType, TreeType, VectorType&gt; {
          vertices, faces, tree,
          origin, dir, VectorType(dir.cwiseInverse())
      };
      
      // ...
  }
  </code></pre>
  <p>But I'm receiving this compile error:</p>
  <pre><code>error: no matching constructor for initialization of 'detail::RayIntersectorHits&lt;Matrix&lt;float, 3, 1, 2, 3, 1&gt;, Matrix&lt;int, 3, 1, 2, 3, 1&gt;, Tree&lt;3, float&gt;, Matrix&lt;double, 3, 1, 2, 3, 1&gt; &gt;'
      auto ray_intersector = detail::RayIntersectorHits&lt;VertexType, IndexedFaceType, TreeType, VectorType&gt; {
                             ^                                                                             ~
  </code></pre>
  <p>I cannot figure out how to bypass the error. I appreciate any help.</p>
  <h2>Resolved</h2>
  <p>The error got resolved by:</p>
  <pre><code>namespace detail {
      template&lt;typename AVertexType, typename AIndexedFaceType, typename ATreeType, typename AVectorType&gt;
      struct RayIntersector {
          using VertexType        = AVertexType;
          using IndexedFaceType   = AIndexedFaceType;
          using TreeType          = ATreeType;
          using VectorType        = AVectorType;
  
          const std::vector&lt;VertexType&gt;       &amp;vertices;
          const std::vector&lt;IndexedFaceType&gt;  &amp;faces;
          const TreeType                      &amp;tree;
  
          const VectorType                     origin;
          const VectorType                     dir;
          const VectorType                     invdir;
  #ifdef CPP17_NOT_AVAILABLE
          // Aggregate initialization for the derived type is a C++17 feature
          // Trying to compile with C++14
          // If you can't upgrade to C++17 standard, you will need to define a constructor in the derived struct.
          RayIntersector(const std::vector&lt;VertexType&gt;        &amp;vertices
                         , const std::vector&lt;IndexedFaceType&gt;     &amp;faces
                         , const TreeType                         &amp;tree
                         , const VectorType                    origin
                         , const VectorType                    dir
                         , const VectorType                    invdir)
              :
                vertices(vertices)
              , faces(faces)
              , tree(tree)
              , origin(origin)
              , dir(dir)
              , invdir(invdir)
          {}
  #endif // CPP17_NOT_AVAILABLE
      };
  
      template&lt;typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType&gt;
      struct RayIntersectorHits : RayIntersector&lt;VertexType, IndexedFaceType, TreeType, VectorType&gt; {
          std::vector&lt;igl::Hit&gt;                hits;
  #ifdef CPP17_NOT_AVAILABLE
          // Aggregate initialization for the derived type is a C++17 feature
          // Trying to compile with C++14
          // If you can't upgrade to C++17 standard, you will need to define a constructor in the derived struct.
          RayIntersectorHits(const std::vector&lt;VertexType&gt;        &amp;vertices
                             , const std::vector&lt;IndexedFaceType&gt;     &amp;faces
                             , const TreeType                         &amp;tree
                             , const VectorType                    origin
                             , const VectorType                    dir
                             , const VectorType                    invdir)
              : RayIntersector&lt;VertexType, IndexedFaceType, TreeType, VectorType&gt;(vertices, faces, tree, origin, dir, invdir) {}
  #endif // CPP17_NOT_AVAILABLE
      };
  } // namespace detail
  </code></pre>