title: invalid use of void expression error in vector
body: <p>in below  code snippet, I am not sure why i am getting error like "invalid use of void expression" while executing
  function object with vector. eventhough it is valid outside vector. </p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  #include&lt;algorithm&gt;
  using namespace std;
  
  class AddVal {
    int i;
  public:
    AddVal (int a) : i(a) {}
    void operator()(int val) {
      cout &lt;&lt; i + val &lt;&lt; endl;
    }
    void operator()(string obj) {
      cout &lt;&lt; "string obj" &lt;&lt; obj;
    }
  };
  
  int main() {
    vector&lt;int&gt; vec = { 1, 2, 3 };
    vector&lt;string&gt; vecs = { "mo", "han", "raj" };
    int x = 2;
    AddVal(2)("john"); // valid
    AddVal(1)(2);      // valid
  //for_each(vecs.begin(), vecs.end(), AddVal(2)("john")); // not valid
    for_each(vec.begin(), vec.end(), AddVal(x));           // valid
    // not valid in vector (invalid use of void expression)
  //for_each(vec.begin(), vec.end(), AddVal(1)(x));
  
    return 1;
  }
  </code></pre>