OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
array_to_string.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 VTT Technical Research Centre of Finland Ltd
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
30#ifndef PFC_UTILS_ARRAY_TO_STRING_HPP
31#define PFC_UTILS_ARRAY_TO_STRING_HPP
32
33#include <array>
34#include <cstddef>
35#include <sstream>
36#include <string>
37
38namespace pfc {
39namespace utils {
40
41template <typename T, std::size_t D>
42std::string array_to_string(const std::array<T, D> &arr) {
43 std::ostringstream oss;
44 oss << '{';
45 for (std::size_t i = 0; i < D; ++i) {
46 oss << arr[i];
47 if (i != D - 1) oss << ", ";
48 }
49 oss << '}';
50 return oss.str();
51}
52
53} // namespace utils
54} // namespace pfc
55
56#endif