Search code examples
c++multithreadingfunctionfunction-declaration

Can someone explain the following strange function declarations?


std::thread f()
{
  void some_function(); // <- here
  return std::thread(some_function);
}

std::thread g()
{
  void some_other_function(int); // <- here
  std::thread t(some_other_function,42);
  return t;
}

Solution

  • Lines like:

    void some_function();
    

    simply declare a function which will be defined later. Functions don't necessarily have to be declared outside of function scope.