From 4974f07209ebc5e0578fc383057b4be383cdf318 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 9 Jun 2021 20:00:02 -0700 Subject: ion_map_ids: static & const access (#2010) This fixes the `ion_map_ids` atom-to-number object: - declare static, so the file can be included in multiple translation units - use `.at()`: - missing entries do not cause an insertion - missing entries will throw - access is `const`, so we can declare the whole object `static const` as well. --- Source/Utils/write_atomic_data_cpp.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Source/Utils/write_atomic_data_cpp.py') diff --git a/Source/Utils/write_atomic_data_cpp.py b/Source/Utils/write_atomic_data_cpp.py index 9070b71ac..d1df7a3ea 100644 --- a/Source/Utils/write_atomic_data_cpp.py +++ b/Source/Utils/write_atomic_data_cpp.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright 2019-2020 Axel Huebl, Luca Fedeli, Maxence Thevenet +# Copyright 2019-2021 Axel Huebl, Luca Fedeli, Maxence Thevenet # # # This file is part of WarpX. @@ -34,11 +34,12 @@ cpp_string += '// Edit dev/Source/Utils/write_atomic_data_cpp.py instead!\n' cpp_string += '#ifndef WARPX_IONIZATION_TABLE_H_\n' cpp_string += '#define WARPX_IONIZATION_TABLE_H_\n\n' cpp_string += '#include \n' -cpp_string += '#include \n' -cpp_string += '#include \n\n' +cpp_string += '#include \n\n' +cpp_string += '#include \n' +cpp_string += '#include \n\n' # Map each element to ID in table -cpp_string += 'std::map ion_map_ids = {' +cpp_string += 'static std::map const ion_map_ids = {' for count, name in enumerate(ion_names): cpp_string += '\n {"' + name + '", ' + str(count) + '},' cpp_string = cpp_string[:-1] -- cgit v1.2.3