Add copy constructor for dynamic_format_arg_store - #2432
Conversation
vitaut
left a comment
There was a problem hiding this comment.
Thanks for the PR. A few small comments inline.
|
Also please add a test case to https://github.com/fmtlib/fmt/blob/master/test/args-test.cc. |
afdc42c to
8fa46fe
Compare
64d8f75 to
940496a
Compare
940496a to
55d3c48
Compare
|
@DanielaE, do you know why msvc complains about |
|
The good news: Spiros' changes are fine, everything builds and all tests pass with msvc 16.10, 16.11-pre3 and 17.0-pre2. 🎉 The bad news: CI has a new windows-2019 image with CMake 3.21 instead of 3.20. The compiler is still the same (16.10.2) I will probably not find enough time today though to switch my local build environment to CMake 3.21 and look into differences in |
|
Everything builds locally with CMake 3.21! 😱 |
|
I accidentally closed this PR, so I reopened it. Is there any progress as far as the Cmake issues? @DanielaE |
|
I just found out that the CMake generators "Visual Studio 16 2019" and "Visual Studio 17 2022" are 'improved' in CMake 3.21 in the sense that they are broken: they swallow the compiler option Whatever I've tried to hide these compiler options from being processed by the generators fell flat. |
|
In that case I suggest temporarily setting Line 89 in 5618346 |
|
Thank you! |
|
Thanks, @DanielaE, for looking into it! |
|
@vitaut I saw in the newest version of fmt this copy-constructor was deleted. Would it be possible to explain why? |
|
IIRC it was broken, you can look up the commit history for more details. |
|
I looked it up, there was not a PR for the commit that did that (be51ee1) or further explanation apart from broken. I am asking because https://github.com/Kitware/ParaView relies on that. Edit: I just saw #2653. so i am gonna follow up there, |
|
@spyridon97 do you know if the CMake issue was addressed which ran afoul with IFC generation? |
Issue: https://gitlab.kitware.com/cmake/cmake/-/issues/22477 has been merged |
The goal of the PR is to develop a copy constructor (and default constructor) for the
dynamic_format_arg_store.The reason behind the need for a copy-constructor as stated in #2431 is that I would like to be able to instantiate a dynamic_format_arg_store object using another one to emulate a scope of arguments based on the class hierarchy of my code.
For the implementation of the copy-constructor, the members:
data_andnamed_info_have been copied, whiledynamic_args_remained untouched because it also did not have a copy constructor or an iterator to implement a copy constructor.Using the implementation included in this PR i was able to successfully do something like below:
fmt::dynamic_format_arg_store<fmt::format_context> dArgs; std::vector<int> v1 = {5, 1235, 1235123}; dArgs.push_back(fmt::arg("global_username", std::ref("utkarsh1"))); dArgs.push_back(fmt::arg("global_hostname", std::ref("miron"))); dArgs.push_back(fmt::arg("global_vector", v1)); fmt::dynamic_format_arg_store<fmt::format_context> dArgs2(dArgs); dArgs2.push_back(fmt::arg("extra", std::ref("extra-value")));Because of the new copy constructor,
dArgsincludes the first 3 variables, anddArgs2includes the first 3 variables plus the 4th one.