void fn(double d) {...}
void test()
{
int i = 1;
double d = 2.0;
auto p = make_unique<int>(0);
explicit {
d = i; //error
fn(i); //error
fn(d); //fn's body does not inherit explicit
bool b = p;
}
}
void test2() explicit; //error for declaration
//some shorthand ways to declar explicit for blocks
void test2() explicit //ok for definition
{
if (condition) explicit {
}
}
explicit void fn(double d) //this explicit applies to function params not the body
{
}
void test()
{
int i = 1;
fn(i); //error
}
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
On 2015–05–21, at 12:11 AM, Michael Boyko <mboyk...@gmail.com> wrote:An explicit block would be a way to write code where implicit conversions would not be generated.
Before going for something like this, there would be a need for some clarifications:
- would there be an impact on constructors within an explicit block, e.g. making all implicit construction explicit within the block?
- what would happen if an explicit function calls a non-explicit function? Would the impact be transitive? Would there be an error?
- can one overload on the explicit-ness of a function?
Please, keep the explicit qualifier within the body of a function, and
not within the function header—this is a function implementation
restriction, and does not affect the way the function is used (unless
I have totally misunderstood the OP).
void fn() explicit {
}
void fn() {
explicit {
}
}
void fn() try {
} catch (...) {
}
Sorry if I missed something, but what problem does this solve? Is this problem so common? Can't it be solved by other means?
On 2015–05–22, at 4:04 AM, Michael Boyko <mboyk...@gmail.com> wrote:I'll point out my personal experience. I've been bit by bugs caused by implicit conversions generally related to overloaded function resolution.
I'm sure we all have been bit by a bug caused by narrowing conversions.