Note that there are some explanatory texts on larger screens.

plurals
  1. POtemplate 'using' declaration not working
    primarykey
    data
    text
    <p>I have the following little test application, where I'm trying to employ a <em>template using</em> declaration.</p> <p>However, it doesn't compile. (I'm using gcc 4.6.1)</p> <blockquote> <p>src/main.cpp:36:3: error: expected unqualified-id before ‘using’</p> </blockquote> <ul> <li>Is my <em>using</em> declaration valid c++?</li> <li>Is it possible to create a template alias without specifying a type for one of the template parameters?</li> <li>Is it possible to create a template alias with a variadic template?</li> </ul> <p>Any insight greatly appreciated!</p> <pre><code>#include &lt;iostream&gt; #include &lt;utility&gt; template&lt;typename F, typename... Args&gt; struct invoke; // specialisation of invoke for 1 parameter template&lt;typename F, typename A0&gt; struct invoke&lt;F, A0&gt; { invoke(F&amp; f_, A0&amp;&amp; a0_) : _f(f_) , _a0(std::move(a0_)) {} void operator()() { _f(_a0); } F _f; A0 _a0; }; template&lt;typename F&gt; struct traits; // fwd declaration for handler struct handler; // specialisation of traits for handler template&lt;&gt; struct traits&lt;handler&gt; { template&lt;class F, typename... Args&gt; using call_t = invoke&lt;F, Args...&gt;; // line 36 }; template&lt;typename F&gt; struct do_it { template&lt;typename... Args&gt; void operator()(F&amp; _f, Args... args) { // create an object of the type declared in traits, and call it typename traits&lt;F&gt;::template call_t&lt;F, Args...&gt; func(_f, std::forward&lt;Args&gt;(args)...); func(); } }; struct handler { void operator()(int i) { std::cout &lt;&lt; i &lt;&lt; std::endl; } }; int main() { handler h; do_it&lt;handler&gt; d; d(h, 4); return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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