arun11299 / cpp-subprocess

Subprocessing with modern C++
Other
456 stars 90 forks source link

static inline functions in a header only library #42

Open klosworks opened 5 years ago

klosworks commented 5 years ago

You have a lot of static inline functions, such as

  static inline std::vector<std::string>
split(const std::string& str, const std::string& delims=" \t")

The problem is, with static functions, the compiler will create a separate internal copy of the function in every translation unit that has included subprocess.hpp. In large projects this can grow to huge numbers. Those functions should be just inline, without static. This way they will be visible to the linker, so it will remove the copies.