Add constructor for dup_filter_sink with sinks parameter#3549
Add constructor for dup_filter_sink with sinks parameter#3549gabime merged 2 commits intogabime:v1.xfrom
Conversation
|
the issue also happens with just std::initializer_list<spdlog::sink_ptr> sinks{
console_sink, file_sink,
std::make_shared<
spdlog::sinks::
null_sink_mt>() /*for POSITON_GAME_LOG id + ".log" */};
spdlog::sinks::dist_sink<std::mutex>().set_sinks(sinks); |
|
The cause is the usage of |
it was actually an issue with lldb 23, the vector size is correct with 19 - I am surprized with the rootcause but will report the issue to LLVM my PR is ready |
|
No, your code is incorrect. As you can see on the cppreference.com page for the Applying the following changes to your code will make it work: + std::vector<spdlog::sink_ptr> sinks({
- std::initializer_list<spdlog::sink_ptr> sinks{
console_sink, file_sink,
std::make_shared<
spdlog::sinks::
+ null_sink_mt>() /*for POSITON_GAME_LOG id + ".log" */});
- null_sink_mt>() /*for POSITON_GAME_LOG id + ".log" */};
spdlog::sinks::dist_sink<std::mutex>().set_sinks(sinks); |
| explicit dup_filter_sink(std::chrono::duration<Rep, Period> max_skip_duration, std::vector<std::shared_ptr<sink>> sinks) | ||
| : dist_sink<Mutex>(std::move(sinks)) | ||
| , max_skip_duration_{max_skip_duration} {} | ||
|
|
There was a problem hiding this comment.
max_skip_duration should be initialized before the vector , to follow the declare order
There was a problem hiding this comment.
https://en.cppreference.com/w/cpp/language/initializer_list.html
- Then, direct bases are initialized in left-to-right order as they appear in this class's base-specifier list.
- Then, non-static data member are initialized in order of declaration in the class definition.
There was a problem hiding this comment.
Even so, the code should be clean as possible
|
@Niram7777 I think this change was created for shadps4-emu/shadPS4#4069, but since the previous suggestion resolved your issue, is this PR no longer needed? |
sorry I have almost no free time during the week, and I am super busy on the weekend. |
"Copying an initializer list does not copy the underlying elements". yes and what the standard says is that it will be a shallow copy -> so the representation will be copied, so the size should not be 0
std::initializer_list<int> il{-3, -2, -1};
assert(il.begin()[2] == -1); // note the replacement for absent operator[]
il = al; // shallow-copy
assert(il.begin() == al.begin()); // guaranteedalso
https://en.cppreference.com/w/cpp/container/vector/vector.html
|
|
Thanks @Niram7777 |


No description provided.