LoginSignup
0
0

More than 3 years have passed since last update.

spdlog(fmtlib)で std::vector を扱う.

Posted at

背景

spdlog(or fmtlib の fmt::print) で, std::vector の数値配列をロギングしたり(行列とか)したい.

方法

spdlog で, fmtlib を有効にしているものとします.

fmtlib の join を使うのが楽でしょうか.

std::vector<float> values{0.0f, 0.2f, 0.3f};
fmt::print("values = [{}]", fmt::join(values, ", "));

// values = [0.0, 0.2, 0.3]

同様にして, std::array も扱うことができます.

ありがとうございます.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0