Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I ended up using a fallback namespace :</p> <pre><code>namespace operators_fallback { template &lt;typename T&gt; inline QDataStream&amp; operator&lt;&lt;(QDataStream&amp; s, const T &amp;) { return s; } template &lt;typename T&gt; inline QDataStream&amp; operator&gt;&gt;(QDataStream&amp; s, T &amp;) { return s; } template &lt;typename T&gt; inline QDebug operator&lt;&lt;(QDebug d, const T &amp;) { return d; } }; ... inline void load(QDataStream &amp; s) { using namespace operator_fallback; s &gt;&gt; item; } </code></pre> <p>Also found the proper way to check for operators at compile time (although I'm going with the fallback namespace).</p> <p>more or less based on <strong>this</strong> :</p> <pre><code>namespace private_impl { typedef char yes; typedef char (&amp;no)[2]; struct anyx { template &lt;class T&gt; anyx(const T &amp;); }; no operator &lt;&lt; (const anyx &amp;, const anyx &amp;); no operator &gt;&gt; (const anyx &amp;, const anyx &amp;); template &lt;class T&gt; yes check(T const&amp;); no check(no); template &lt;typename StreamType, typename T&gt; struct has_loading_support { static StreamType &amp; stream; static T &amp; x; static const bool value = sizeof(check(stream &gt;&gt; x)) == sizeof(yes); }; template &lt;typename StreamType, typename T&gt; struct has_saving_support { static StreamType &amp; stream; static T &amp; x; static const bool value = sizeof(check(stream &lt;&lt; x)) == sizeof(yes); }; template &lt;typename StreamType, typename T&gt; struct has_stream_operators { static const bool can_load = has_loading_support&lt;StreamType, T&gt;::value; static const bool can_save = has_saving_support&lt;StreamType, T&gt;::value; static const bool value = can_load &amp;&amp; can_save; }; } template&lt;typename T&gt; struct supports_qdatastream : private_impl::has_stream_operators&lt;QDataStream, T&gt; {}; template&lt;typename T&gt; struct can_load : private_impl::has_loading_support&lt;QDataStream, T&gt; {}; template&lt;typename T&gt; struct can_save : private_impl::has_saving_support&lt;QDataStream, T&gt; {}; template&lt;typename T&gt; struct can_debug : private_impl::has_saving_support&lt;QDebug, T&gt; {}; </code></pre> <p>//edit changed has_stream_operators a bit.</p> <p>//edit removed the link, apparently the site has some attack javascript.</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