Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You've provided a <em>template</em> where a <em>type</em> is expected.</p> <p>For what it's worth, GCC 4.8 gives a decent diagnostic:</p> <pre><code>template &lt;typename&gt; struct Foo; template &lt;typename&gt; struct Bar; int main() { Foo&lt;Bar&gt; x; } </code></pre> <p>Diagnostic:</p> <pre class="lang-none prettyprint-override"><code>In function ‘int main()’: error: type/value mismatch at argument 1 in template parameter list for ‘template&lt;class&gt; struct Foo’ Foo&lt;Bar&gt; x; ^ error: expected a type, got ‘Bar’ </code></pre> <p>(GCC got a lot better since Clang started producing very nice error messages, so this may be recent; I imagine Clang would also give a useful error here.)</p> <hr> <p>Concerning your updated question: The typical way to make a container adapter, or generally a class that needs a certain container which you want to be customizable, is to pass the entire container as a template parameter:</p> <pre><code>template &lt;typename XContainer, typename YContainer&gt; struct Database { XContainer xstorage; YContainer ystorage; }; Database&lt;std::map&lt;int, double&gt;, std::unordered_map&lt;std::string, double&gt;&gt; db; db.xstorage[1] = 2.5; db.ystorage["foo"] = 4.5; </code></pre> <p>This is the most general solution since you can use <em>any</em> class that fits your needs, without requiring that class to have any particular structure.</p> <p>As an alternative (<em>which I do not recommend</em>), if you want all your containers to be template specializations of the same template, you can pass the template in directly as a template parameer (a so-called template template parameter):</p> <pre><code>template &lt;template &lt;typename, typename, typename...&gt; class CTmpl, typename XType, typename YType&gt; struct Database { CTmpl&lt;XType, double&gt; x; CTmpl&lt;YType, double&gt; y; }; Database&lt;std::map, int, std::string&gt; db; // as above </code></pre> <p>This is a lot more restrictive: not only does your database now have to use the same data structure for everything, but the data structure also <em>has</em> to be given as a template with fixed first two parameters "key type" and "mapped type".</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload