title: Invalid declarator before with map of struct?
body: <p>I'm trying to map a mapping between <code>string</code>s and a custom struct, <code>callable</code>. However, it's giving me "invalid declarator". I've tried a bunch of things, like <code>typedef</code>ing it (e.g. <code>typdef struct _c { } callable;</code>) but that just raises more errors.</p>
  
  <p>I'm compiling with ideone.com, since I don't have a compiler at school but I still want to at least bang out decent code.</p>
  
  <p>A minimum example (<a href="http://ideone.com/zl7dn6" rel="nofollow">ideone link</a>):</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;map&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  struct callable {
    virtual void operator()(vector&lt;string&gt; args) = 0;
  }
  
  std::map&lt;std::string, callable&gt; commands =
  {
    { "cmd", struct : callable
      {
        operator()(vector&lt;string&gt; args) {
          out &lt;&lt; "cmd called with args:" &lt;&lt; endl;
          for (auto i = args.begin(); args.end() != i; ++i) out &lt;&lt; *i &lt;&lt; endl;
        }
      }
    }
  }
  
  int main() {
    vector&lt;string&gt; args = {"hello", "world"};
    commands["cd"](args);
  }
  </code></pre>
  
  <p>And the error is:</p>
  
  
  
  <pre class="lang-none prettyprint-override"><code>prog.cpp:11:33: error: invalid declarator before 'commands'
   std::map&lt;std::string, callable&gt; commands =
                                   ^
  </code></pre>
  
  <p>The expected output:</p>
  
  <pre class="lang-none prettyprint-override"><code>cmd called with args:
  hello
  world
  </code></pre>
  
  <hr>
  
  <p>As a side note, please provide an answer to this question before answering the more general question of mapping strings to code, unless this approach can't work.</p>