what is a good alternative to this ugly construct, in c++?
<p>This is my code (simplification of a real-life problem):</p>

<pre><code>class Foo {
public:
  void f(const string&amp; s) {
    if (s == "lt") {
      return lt();
    } else if (s == "lte")
      return lte();
    } else if (s == "gt")
      return gt();
    } else if (s == "gte")
      return gte();
    }
  }
  void lt() { /* skipped */ }
  void lte() { /* skipped */ }
  void gt() { /* skipped */ }
  void gte() { /* skipped */ }
};
</code></pre>

<p>This is how I would do it in PHP/Python/JavaScript/many other languages (example in PHP):</p>

<pre><code>class Foo {
  function f($s) {
    return $this-&gt;$s();
  }
  function lt() { /* skipped */ }
  function lte() { /* skipped */ }
  function gt() { /* skipped */ }
  function gte() { /* skipped */ }
}
</code></pre>

<p>How can I make my C++ code as elegant as this PHP example? Thanks in advance.</p>
