Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>GCC does not provide such a mechanism as you want. However you will not need it if you are able to refactor your code somewhat as illustrated in the following program. (I have filled in a few gaps so as to give us a compilable example):</p> <pre><code>#include &lt;type_traits&gt; #include &lt;vector&gt; template&lt;typename ContainerType&gt; struct is_container { static bool const value = false; }; template&lt;&gt; struct is_container&lt;std::vector&lt;int&gt;&gt; { static bool const value = true; }; template&lt;typename ContainerType&gt; struct IsContainerCheck // : is_container&lt;ContainerType&gt; &lt;- Uneccessary { static_assert(is_container&lt;ContainerType&gt;::value, "Type is not a container model"); }; namespace _check_concept { template&lt;typename ResultType&gt; struct run { constexpr static int apply() { return (IsContainerCheck&lt;ResultType&gt;(),0); } }; // No such specialization is necessary. Delete it. // template&lt;&gt; // struct run&lt;true_t&gt; { // constexpr static int apply() { // return 0; // } //}; } using namespace _check_concept; int main(int argc, char **argv) { auto verdict0 = run&lt;std::vector&lt;int&gt;&gt;::apply(); (void)verdict0; // The following line will static_assert: "Type is not a container model" auto verdict1 = run&lt;float&gt;::apply(); (void)verdict1; return 0; } </code></pre> <p>In your specialization <code>_check_concept::struct run&lt;true_t&gt;</code> I presume that <code>true_t</code> is <em>not</em> an alias or equivalent of <code>std::true_type</code>, but rather just a place-holder for <em>some <code>ResultType</code> that is a container type</em>. As the test program shows, no such specialization is now necessary, because <code>IsContainerCheck&lt;ResultType&gt;()</code> will <code>static_assert</code>, or not, depending on <code>ResultType</code>, in the unspecialized <code>run&lt;ResultType&gt;::apply()</code>.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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