Skip to content

Commit 6350455

Browse files
author
Werner Henze
committed
Better use of std::enable_if
Replace the occurances of `class = std::enable_if_t<Cond>` and `typename = std::enable_if_t<Cond>` that have been identified in the previous commit with `std::enable_if_t<Cond, bool> = true`. This commit is inspired by #1174, which changed one occurance in the owner header. This commit is aimed to fix all remaining occurances.
1 parent a4356d5 commit 6350455

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

docs/headers.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,16 @@ See [SL.str.5: Use `std::byte` to refer to byte values that do not necessarily r
9191
### Non-member functions
9292
9393
```cpp
94-
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
94+
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
9595
constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept;
9696
97-
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
97+
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
9898
constexpr byte operator<<(byte b, IntegerType shift) noexcept;
9999
100-
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
100+
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
101101
constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept;
102102
103-
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
103+
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
104104
constexpr byte operator>>(byte b, IntegerType shift) noexcept;
105105
```
106106

@@ -134,7 +134,7 @@ constexpr byte operator~(byte b) noexcept;
134134
Bitwise negation of a `byte`. Flips all bits. Zeroes become ones, ones become zeroes.
135135

136136
```cpp
137-
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
137+
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
138138
constexpr IntegerType to_integer(byte b) noexcept;
139139
```
140140
@@ -310,7 +310,7 @@ auto make_not_null(T&& t) noexcept;
310310
Creates a `gsl::not_null` object, deducing the target type from the type of the argument.
311311

312312
```cpp
313-
template <typename T, typename = std::enable_if_t<std::is_move_assignable<T>::value && std::is_move_constructible<T>::value>>
313+
template <typename T, std::enable_if_t<std::is_move_assignable<T>::value && std::is_move_constructible<T>::value, bool> = true>
314314
void swap(not_null<T>& a, not_null<T>& b);
315315
```
316316

include/gsl/byte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,25 @@ enum class byte_may_alias byte : unsigned char
9191
{
9292
};
9393

94-
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
94+
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
9595
constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept
9696
{
9797
return b = byte(static_cast<unsigned char>(b) << shift);
9898
}
9999

100-
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
100+
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
101101
constexpr byte operator<<(byte b, IntegerType shift) noexcept
102102
{
103103
return byte(static_cast<unsigned char>(b) << shift);
104104
}
105105

106-
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
106+
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
107107
constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept
108108
{
109109
return b = byte(static_cast<unsigned char>(b) >> shift);
110110
}
111111

112-
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
112+
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
113113
constexpr byte operator>>(byte b, IntegerType shift) noexcept
114114
{
115115
return byte(static_cast<unsigned char>(b) >> shift);
@@ -147,7 +147,7 @@ constexpr byte operator^(byte l, byte r) noexcept
147147

148148
constexpr byte operator~(byte b) noexcept { return byte(~static_cast<unsigned char>(b)); }
149149

150-
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
150+
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
151151
constexpr IntegerType to_integer(byte b) noexcept
152152
{
153153
return static_cast<IntegerType>(b);

include/gsl/pointers

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private:
145145
T ptr_;
146146
};
147147

148-
template <typename T, typename = std::enable_if_t<std::is_move_assignable<T>::value && std::is_move_constructible<T>::value>>
148+
template <typename T, std::enable_if_t<std::is_move_assignable<T>::value && std::is_move_constructible<T>::value, bool> = true>
149149
void swap(not_null<T>& a, not_null<T>& b)
150150
{
151151
a.swap(b);

0 commit comments

Comments
 (0)