New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
static_assert
vs SFINAE
#3
Comments
Should be SFINAE + |
I don't see how this issue is related. To which operations are you referring to? |
@viboes: I think you're right. In that comment, I was referring to constructors. That is, |
Ah I see how the issue is related to these constructors. The overloaded constructor should not participate in overload resolution until Foo is one of the types. I don't see what do you mean by + = delete. There is nothing to delete. SFINAE do everything; isn't it? |
I think semantically they would behave the same. It came up because the current proposal is worded as follows:
Perhaps we need to revisit the wording and consider the SFINAE wording of "does not participate in overload resolution". In terms of the actual implementation, #include <iostream>
#include <type_traits>
struct Bar {
Bar() = delete;
};
template <typename T>
struct Foo {
template <typename U = T,
std::enable_if_t<std::is_default_constructible<U>::value, int> = 0>
Foo() {}
template <typename U = T,
std::enable_if_t<!std::is_default_constructible<U>::value, int> = 0>
Foo() = delete;
};
int main() {
static_assert(!std::is_default_constructible<Bar>::value, "");
static_assert(!std::is_default_constructible<Foo<Bar>>::value, "");
} This compiles successfully with or without the presence of the deleted constructor. If I were to attempt to construction however, the error messages are different: With
whereas without the
|
I see. I would let this as an implementation detail. |
Yep. The updated proposal will use the SFINAE wording for these constructors. |
For type-based operations, there must be exactly one instance of
T
in the list of alternatives.Determine whether this violation should be a
static_assert
within the function or a SFINAE += delete;
.The text was updated successfully, but these errors were encountered: