Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-01-10 14:28:23 +0300
committerJacques Lucke <jacques@blender.org>2022-01-10 14:28:33 +0300
commitbd8fa07a3df6d55ca83778253a3ccaa5a9ca4660 (patch)
tree20b66dc066354ab9983964b3f3008f23ad29b147 /source/blender/blenlib/BLI_vector.hh
parent934db6a8201afe9b137ff41a3bf3f1da6b32ca02 (diff)
Cleanup: add utility macro to simplify using std::enable_if
Diffstat (limited to 'source/blender/blenlib/BLI_vector.hh')
-rw-r--r--source/blender/blenlib/BLI_vector.hh14
1 files changed, 6 insertions, 8 deletions
diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh
index 4ac48f259cf..1b10a4c0897 100644
--- a/source/blender/blenlib/BLI_vector.hh
+++ b/source/blender/blenlib/BLI_vector.hh
@@ -163,7 +163,7 @@ class Vector {
/**
* Create a vector from a span. The values in the vector are copy constructed.
*/
- template<typename U, typename std::enable_if_t<std::is_convertible_v<U, T>> * = nullptr>
+ template<typename U, BLI_ENABLE_IF((std::is_convertible_v<U, T>))>
Vector(Span<U> values, Allocator allocator = {}) : Vector(NoExceptConstructor(), allocator)
{
const int64_t size = values.size();
@@ -178,7 +178,7 @@ class Vector {
* This allows you to write code like:
* Vector<int> vec = {3, 4, 5};
*/
- template<typename U, typename std::enable_if_t<std::is_convertible_v<U, T>> * = nullptr>
+ template<typename U, BLI_ENABLE_IF((std::is_convertible_v<U, T>))>
Vector(const std::initializer_list<U> &values) : Vector(Span<U>(values))
{
}
@@ -187,9 +187,7 @@ class Vector {
{
}
- template<typename U,
- size_t N,
- typename std::enable_if_t<std::is_convertible_v<U, T>> * = nullptr>
+ template<typename U, size_t N, BLI_ENABLE_IF((std::is_convertible_v<U, T>))>
Vector(const std::array<U, N> &values) : Vector(Span(values))
{
}
@@ -197,7 +195,7 @@ class Vector {
template<typename InputIt,
/* This constructor should not be called with e.g. Vector(3, 10), because that is
* expected to produce the vector (10, 10, 10). */
- typename std::enable_if_t<!std::is_convertible_v<InputIt, int>> * = nullptr>
+ BLI_ENABLE_IF((!std::is_convertible_v<InputIt, int>))>
Vector(InputIt first, InputIt last, Allocator allocator = {})
: Vector(NoExceptConstructor(), allocator)
{
@@ -326,13 +324,13 @@ class Vector {
return MutableSpan<T>(begin_, this->size());
}
- template<typename U, typename std::enable_if_t<is_span_convertible_pointer_v<T, U>> * = nullptr>
+ template<typename U, BLI_ENABLE_IF((is_span_convertible_pointer_v<T, U>))>
operator Span<U>() const
{
return Span<U>(begin_, this->size());
}
- template<typename U, typename std::enable_if_t<is_span_convertible_pointer_v<T, U>> * = nullptr>
+ template<typename U, BLI_ENABLE_IF((is_span_convertible_pointer_v<T, U>))>
operator MutableSpan<U>()
{
return MutableSpan<U>(begin_, this->size());