Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>MESONS pi = PI(); MATTER mat = pi; assert (pi == mat); </code></pre> <p>Do you mind a little C++11 template magic?</p> <pre><code>template &lt;typename T, typename... L&gt; struct is_defined_in : std::false_type {}; template &lt;typename T, typename U, typename... L&gt; struct is_defined_in&lt;T, U, L...&gt; : is_defined_in&lt;T, L...&gt; {}; template &lt;typename T, typename... L&gt; struct is_defined_in&lt;T, T, L...&gt; : std::true_type {}; template &lt;int ID&gt; struct helper { friend bool operator==(helper a, helper b) { return a.id == b.id; } friend bool operator!=(helper a, helper b) { return a.id != b.id; } int id=ID; }; template &lt;typename... B&gt; struct category { int id; template &lt;typename T, typename = typename std::enable_if&lt;is_defined_in&lt;T, B...&gt;::value&gt;::type&gt; category(T t) : id(t.id) {} friend bool operator==(category a, category b) { return a.id == b.id; } friend bool operator!=(category a, category b) { return a.id != b.id; } }; enum class ElementaryParticleTypesID { PI, PROTON, NEUTRON, ELECTRON }; struct PI : helper&lt;(int)ElementaryParticleTypesID::PI&gt; {}; struct PROTON : helper&lt;(int)ElementaryParticleTypesID::PROTON&gt; {}; struct NEUTRON : helper&lt;(int)ElementaryParticleTypesID::NEUTRON&gt; {}; struct ELECTRON : helper&lt;(int)ElementaryParticleTypesID::ELECTRON&gt; {}; using MESONS = category&lt;PI&gt;; using BARYONS = category&lt;PROTON, NEUTRON&gt;; using LEPTONS = category&lt;ELECTRON&gt;; using MATTER = category&lt;MESONS, BARYONS, LEPTONS&gt;; </code></pre> <p>(<code>the static_assert</code> currently doesn't work beyond two hierarchies, but this can be added if you want to)</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. 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