X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5930585fb6f11543a87e4c5c72356ac89222237c..30b4f947d87ffdc4bccdb56fa4be9514780daf9b:/include/xbt/functional.hpp diff --git a/include/xbt/functional.hpp b/include/xbt/functional.hpp index c09d278254..cc053a56a2 100644 --- a/include/xbt/functional.hpp +++ b/include/xbt/functional.hpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -38,15 +39,9 @@ public: { const int argc = args_->size(); std::vector args = *args_; - if (not args.empty()) { - char noarg[] = {'\0'}; - auto argv = std::make_unique(argc + 1); - for (int i = 0; i != argc; ++i) - argv[i] = args[i].empty() ? noarg : &args[i].front(); - argv[argc] = nullptr; - code_(argc, argv.get()); - } else - code_(argc, nullptr); + std::vector argv(args.size() + 1); // argv[argc] is nullptr + std::transform(begin(args), end(args), begin(argv), [](std::string& s) { return &s.front(); }); + code_(argc, argv.data()); } };