title: C++ - Why is std::function<some_type_t, void> invalid?
body: <p>In C++, if I try to do this:</p>
  
  <pre><code>std::function&lt;void(bool,void)&gt;
  </code></pre>
  
  <p>then the compiler will throw errors. Why is this? It's useful in many cases. One example:</p>
  
  <pre><code>//g++ -std=c++17 prblm.cpp
  #include &lt;cstdio&gt;
  #include &lt;functional&gt;
  
  template&lt;class type_t&gt;
  class some_callback
  {
      public:
          using callback_t = std::function&lt;void(bool,type_t)&gt;;
          some_callback(callback_t _myfunc)
          {
              this-&gt;myfunc = _myfunc;
          }
          callback_t myfunc;
  };
  
  using callback_with_just_bool = some_callback&lt;void&gt;;
  using callback_with_an_int_too = some_callback&lt;int&gt;;
  
  int main()
  {
      auto my_callback_with_int = callback_with_an_int_too([](bool x, int y)
      {
      }); //OK
  
      auto my_callback_just_bool = callback_with_just_bool([](bool x)
      {
      }); //Error
  
      auto my_callback_just_bool = callback_with_just_bool([](bool x,void z)
      {
      }); //Error
      return 0;
  }
  </code></pre>
  
  <p>This allows for a very clean syntax if the user would like to optionally have additional data in their callback, but not have to. However, the compiler will reject code that tries to initialize an object of <code>callback_with_just_bool</code></p>
  
  <p>Why is it like this, and is there a clean way around it? Thanks.</p>
  
  <p>Edit: The specific reason I'm trying to do this, in real world code, is in an event system. There is data provided to the event system about an individual object that wishes to <em>conditionally</em> receive events (e.x. "if you're close enough to the source, you'll receive a sound event") as well as data provided to a callback <em>about</em> the event (e.x. "a 10khz noise at X200 Y200"). Most of the time, the data needed to check the requirements will exist inside the data provided to the callback <em>about</em> the event, but I wanted to provided an optional additional data structure if that was not the case. Hence, the user would specify "void" if they didn't need this additional data structure. </p>