Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Marcelo Cantos's answer is, of course, the proper way to do things. However, there is the complicated and crazy workaround of specialization. (Not recommended.)</p> <pre><code>//if it's a class, inherit from it to get public members template&lt;class T&gt; class proxy_element : public T { ... proxy_element(Vector&lt;T&gt;&amp; m_parent, const size_type index); proxy_elem&amp; operator=(const T&amp; rhs); // modifies data so invalidate on other memories bool operator==(const proxy_elem&amp; rhs) // only read, just copy data back. ... }; //pretend to be a pointer template&lt;&gt; class proxy_element&lt;T*&gt; { ... proxy_element(Vector&lt;T&gt;&amp; m_parent, const size_type index); proxy_elem&amp; operator=(const T&amp; rhs); // modifies data so invalidate on other memories bool operator==(const proxy_elem&amp; rhs) // only read, just copy data back. ... }; //otherwise, pretend to be primitive #define primitive_proxy(T) \ template&lt;&gt; class proxy_element { ... proxy_element(Vector&lt;T&gt;&amp; m_parent, const size_type index); proxy_elem&amp; operator=(const T&amp; rhs); // modifies data so invalidate on other memories bool operator==(const proxy_elem&amp; rhs) // only read, just copy data back. ... }; primitive_proxy(char) primitive_proxy(unsigned char) primitive_proxy(signed char) //this is distinct from char remember primitive_proxy(short) primitive_proxy(unsigned short) primitive_proxy(int) primitive_proxy(unsigned int) primitive_proxy(long) primitive_proxy(unsigned long) primitive_proxy(long long) primitive_proxy(unsigned long long) primitive_proxy(char16_t) //if GCC primitive_proxy(char32_t) //if GCC primitive_proxy(wchar_t) primitive_proxy(float) primitive_proxy(double) primitive_proxy(long double) </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.
    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