Skip to content
Snippets Groups Projects
Commit d562f2c1 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[timeloop][setcp] use init_list over vector

The overload with iterators allow insertion from preexisting containers,
while the overload with std::vector allowed for a terser syntax like
`setCheckPoint({1.0, 2.0})`. But template instantiation failed with this
type of syntax because the scalar type on vector could not be deduced.
parent fc9a116f
No related branches found
No related tags found
1 merge request!3648Feature/improve timeloop
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <iomanip> #include <iomanip>
#include <chrono> #include <chrono>
#include <type_traits> #include <type_traits>
#include <initializer_list>
#include <dune/common/float_cmp.hh> #include <dune/common/float_cmp.hh>
#include <dune/common/timer.hh> #include <dune/common/timer.hh>
...@@ -631,12 +632,17 @@ public: ...@@ -631,12 +632,17 @@ public:
} }
/*! /*!
* \brief add checkpoints to the queue from a vector of time points * \brief add checkpoints to the queue from a list of time points
* \note checkpoints have to be provided in ascending order * \note checkpoints have to be provided in ascending order
* \param checkPoints the vector of check points * \param checkPoints the list of check points
* \note This also updates the time step size and potentially reduces the time step size to meet the next check point * \note This also updates the time step size and potentially reduces the time step size to meet the next check point
*/ */
template<class ScalarOrDuration> template<class ScalarOrDuration>
void setCheckPoint(const std::initializer_list<ScalarOrDuration>& checkPoints)
{ setCheckPoint(checkPoints.begin(), checkPoints.end()); }
template<class ScalarOrDuration>
[[deprecated("Use setCheckpoint(begin, end) instead. Will be removed after release 3.9.")]]
void setCheckPoint(const std::vector<ScalarOrDuration>& checkPoints) void setCheckPoint(const std::vector<ScalarOrDuration>& checkPoints)
{ setCheckPoint(checkPoints.begin(), checkPoints.end()); } { setCheckPoint(checkPoints.begin(), checkPoints.end()); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment