2

Here is code, I don't understand star sign(*) in std::string(*)

using boost::algorithm::join;
using boost::adaptors::transformed;
auto tostr = static_cast<std::string(*)(int)>(std::to_string);

Here is original code

Community
  • 1
  • 1
chikadance
  • 3,591
  • 4
  • 41
  • 73

1 Answers1

5

It's a pointer to function accepting int parameter and returning std::string - exactly what std::to_string does.

As @PeteBecker pointed out, the cast there is needed because there are actuall multiple overloads for to_string, accepting different arguments (ints, doubles, shorts, etc). The cast allows the compiler to pick one of them.

SergeyA
  • 61,605
  • 5
  • 78
  • 137