Class indexer for C++
<p>I'm working on re-implementing <a href="http://research.microsoft.com/en-us/downloads/73099525-fd8d-4966-9b93-574e6023147f/" rel="nofollow">Microsoft PINQ framework</a> using C++ and at some point I need <a href="http://msdn.microsoft.com/en-us/library/6x16t2tx.aspx" rel="nofollow">"Class indexer" feature of C#</a> in my C++ implementation (and I'm curious if there is some solution to Java too). Can any one suggest a good library or something to use?</p>

<p>The C# class:</p>

<pre><code>    /// &lt;summary&gt;
/// PINQAgent class resulting from the Partition operation. 
/// Contains a list of epsilon values, and tracks the maximum value.
/// Increments to the maximum are forwarded to the source IQueryable.
/// Requests that do not increment the maximum are accepted.

/// &lt;/summary&gt;

/// &lt;typeparam name="K"&gt;The type of the key used to partition the data set.&lt;/typeparam&gt;

//this feature is called Indexers http://msdn.microsoft.com/en-us/library/6x16t2tx.aspx

public class PINQAgentPartition&lt;K&gt; : PINQAgent
{
    private PINQAgent target;               // agent of data source that has been partitioned.
    private double[] maximum;               // should be shared
    private Dictionary&lt;K, double&gt; table;    // dictionary shared among several PINQAgentPartitions.
    private K key;                          // key associated with *this* PINQAgentPartition.

    /// &lt;summary&gt;
    /// Accepts iff the increment to the maximum value is accepted by the target.
    /// &lt;/summary&gt;

    /// &lt;param name="epsilon"&gt;epsilon&lt;/param&gt;
    /// &lt;returns&gt;Accepts if the increment to the maximum value is accepted by the target.&lt;/returns&gt;

    public override bool apply(double epsilon)
    {

        // if we increment the maximum, test and update
        if (table[key] + epsilon &gt; maximum[0])
        {
            if (target.apply((table[key] + epsilon) - maximum[0]))
            {
                table[key] += epsilon;
                maximum[0] = table[key];
                return true;
            }
            return false;
        }

        // if we were the maximum, and we decrement, re-establish the maximum.
        if (table[key] == maximum[0] &amp;&amp; epsilon &lt; 0.0)
        {
            table[key] += epsilon;
            maximum[0] = table.Select(x =&gt; x.Value).Max();
        }
        else
            table[key] += epsilon;

        return true;
    }

    /// &lt;summary&gt;
    /// Constructor for PINQAgentPartition
    /// &lt;/summary&gt;

    /// &lt;param name="t"&gt;Target PINQAgent&lt;/param&gt;

    /// &lt;param name="tbl"&gt;Table of (key,epsilon) pairs&lt;/param&gt;

    /// &lt;param name="k"&gt;Key associated with this agent&lt;/param&gt;

    /// &lt;param name="m"&gt;Stores a shared maximum between all peers&lt;/param&gt;

    public PINQAgentPartition(PINQAgent t, Dictionary&lt;K, double&gt; tbl, K k, double[] m)
    {
        target = (t == null) ? new PINQAgent() : t;
        table = tbl;
        key = k;
        maximum = m;
    }
};
</code></pre>

<p>Note: I use g++ compiler under Linux platform</p>
