-
Notifications
You must be signed in to change notification settings - Fork 108
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
Fix implementation of gsl_REQUIRES_T_() #238
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -603,7 +603,7 @@ | |
// For functions, prefer return-type SFINAE if possible. | ||
// If return-type SFINAE is not applicable, use `gsl_REQUIRES_A_()` or `typename std::enable_if< VA, int >::type = 0` in the function template argument list. | ||
// | ||
// Use `gsl_REQUIRES_T_()` or `typename = typename std::enable_if< VA, ::gsl::detail::enabler >::type` in class template argument lists. | ||
// Use `gsl_REQUIRES_T_()` or `typename std::enable_if< (VA), int >::type = 0` in class template argument lists. | ||
|
||
#if gsl_HAVE( EXPRESSION_SFINAE ) | ||
# define gsl_DECLTYPE_(T, EXPR) decltype( EXPR ) | ||
|
@@ -612,7 +612,12 @@ | |
#endif | ||
|
||
#if gsl_HAVE( TYPE_TRAITS ) | ||
# define gsl_REQUIRES_T_(VA) , typename = typename std::enable_if< ( VA ), ::gsl::detail::enabler >::type | ||
# if gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 1, 140 ) | ||
// VS 2013 and earlier seem to have trouble with SFINAE for default non-type arguments | ||
# define gsl_REQUIRES_T_(VA) , typename = typename std::enable_if< ( VA ), ::gsl::detail::enabler >::type | ||
# else | ||
# define gsl_REQUIRES_T_(VA) , typename std::enable_if< ( VA ), int >::type = 0 | ||
# endif | ||
#else | ||
# define gsl_REQUIRES_T_(VA) | ||
#endif | ||
|
@@ -1085,13 +1090,12 @@ struct is_compatible_container : std17::bool_constant | |
|
||
template< | ||
class C, class E | ||
, typename = typename std::enable_if< | ||
gsl_REQUIRES_T_(( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that SFINAE via default template type arguments is fine in class definitions. (The two subsequent arguments Also, our SFINAE Guidelines say that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commenting at the toplevel. |
||
! is_span< C >::value | ||
&& ! is_array< C >::value | ||
&& ! is_std_array< C >::value | ||
&& ( std::is_convertible< typename std::remove_pointer<decltype( std17::data( std::declval<C&>() ) )>::type(*)[], E(*)[] >::value) | ||
// && has_size_and_data< C >::value | ||
, enabler>::type | ||
)) | ||
, class = decltype( std17::size(std::declval<C>()) ) | ||
, class = decltype( std17::data(std::declval<C>()) ) | ||
> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this change? I understand that we want to use
typename std::enable_if< X, int >::type = 0
rather thantypename = typename std::enable_if< X >::type
in function templates, but we already havegsl_REQUIRES_A_()
for that purpose.If the latter form is not required anywhere, perhaps we should remove
gsl_REQUIRES_T_()
altogether?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah great, you awoke me :) I have generalized the note about function templates to include class templates :)
Thus there is no reason for this change left.