1 /* Copyright (c) 2015-2022. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include <simgrid/config.h>
7 #include <xbt/string.hpp>
8 #include <xbt/sysdep.h>
13 namespace simgrid::xbt {
17 char string::NUL = '\0';
21 std::string string_vprintf(const char *fmt, va_list ap)
26 int size = std::vsnprintf(nullptr, 0, fmt, ap2);
28 xbt_assert(size >= 0, "string_vprintf error");
30 // Allocate the string and format:
34 xbt_assert(std::vsnprintf(&res[0], size + 1, fmt, ap) == size, "string_vprintf error");
38 std::string string_printf(const char *fmt, ...)
44 res = string_vprintf(fmt, ap);
54 } // namespace simgrid::xbt