-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
CTAD: class template argument deduction
Such thing will allow this use case, in C++20 and higher.
#include <boost/safe_numerics/safe_integer.hpp>
void uncontrolled(double*, int); // true external function
using boost::safe_numerics::safe;
int main() {
std::vector<double> v = {1.0, 2.0, 3.0};
uncontrolled(v.data(), safe<int>{v.max_size()}); // ok, throws
// uncontrolled(v.data(), safe{v.max_size()}); // needs CTAD
}complete code: https://godbolt.org/z/s8bYz9rqb
The most basic code for this feature could be:
#if define(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201703L)
namespace boost::safe_numerics {
template<class In> safe_base(In) -> safe_base<In>;
}
#endifMetadata
Metadata
Assignees
Labels
No labels