diff --git a/HISTORY.md b/HISTORY.md index bfbc8e6c74..7e45158018 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -13,6 +13,8 @@ _????-??-??_ * Fix compilation if only including `mlpack/methods/kde/kde_model.hpp` (#3800). + * Fix serialization and `MinDistance()` bugs with `HollowBallBound` (#3808). + ## mlpack 4.5.0 _2024-09-17_ diff --git a/doc/developer/trees.md b/doc/developer/trees.md index 739b1d5538..7ac62e5c38 100644 --- a/doc/developer/trees.md +++ b/doc/developer/trees.md @@ -222,7 +222,7 @@ class ExampleTree template ExampleTree( Archive& ar, - const typename std::enable_if_c::type* = 0); + const std::enable_if_t* = 0); // Release any resources held by the tree. ~ExampleTree(); @@ -476,7 +476,7 @@ archive: template ExampleTree( Archive& ar, - const typename std::enable_if_c::type* = 0); + const std::enable_if_t* = 0); ``` This has implications on how the tree must be stored. In this case, the dataset diff --git a/doc/img/hollowballbound.png b/doc/img/hollowballbound.png new file mode 100644 index 0000000000..3660328b3a Binary files /dev/null and b/doc/img/hollowballbound.png differ diff --git a/doc/sidebar.html b/doc/sidebar.html index 6c16944f3e..889e4182c1 100644 --- a/doc/sidebar.html +++ b/doc/sidebar.html @@ -96,6 +96,11 @@ when the sidebar is built for each page. MeanSplitBallTree +
  • + + VPTree + +
  • RPTree diff --git a/doc/user/core/trees/binary_space_tree.md b/doc/user/core/trees/binary_space_tree.md index 4c7c0fdb4d..87952e1592 100644 --- a/doc/user/core/trees/binary_space_tree.md +++ b/doc/user/core/trees/binary_space_tree.md @@ -413,7 +413,7 @@ class uses a hyperrectangle bound. An example `HRectBound` is shown below; the bound is the smallest rectangle that encloses all of the points.
    -hyperrectangle bound enclosing points +hyperrectangle bound enclosing points
    mlpack supplies several drop-in `BoundType` classes, and it is also possible to @@ -423,6 +423,8 @@ write a custom `BoundType` for use with `BinarySpaceTree`: points in the smallest possible hyperrectangle * [`BallBound`](#ballbound): ball bound, encloses the descendant points in the ball with the smallest possible radius + * [`HollowBallBound`](#hollowballbound): hollow ball bound, equivalent to a + ball bound with a ball subtracted from it. * [Custom `BoundType`s](#custom-boundtypes): implement a fully custom `BoundType` @@ -577,7 +579,7 @@ operations with data points or other bounds. Once an `HRectBound` has been successfully created and set to the desired bounding hyperrectangle, there are a number of functions that can bound the -distance between a `HRectBound` and other objects. +distance between an `HRectBound` and other objects. * `b.Contains(point)` * `b.Contains(bound)` @@ -776,7 +778,7 @@ std::cout << "Distance between Manhattan distance HRectBound and " // point. arma::fmat floatData(3, 25, arma::fill::randu); mlpack::HRectBound cb; -cb |= floatData; // This will set the bound to [2.0, 3.0] in every dimension. +cb |= floatData; // Note the use of arma::fvec to represent a point, since ElemType is float. const mlpack::RangeType r3 = cb.RangeDistance(arma::fvec("1.5 1.5 4.0")); std::cout << "Distance between Chebyshev distance HRectBound and " @@ -840,8 +842,8 @@ Different constructor forms can be used to specify different template parameters any points at all). ***Note***: these constructors provide an empty bound; be sure to -[grow](#growing-and-shrinking-the-bound) the bound or -[directly modify the bound](#accessing-and-modifying-properties-of-the-bound) +[grow](#growing-the-bound) the bound or +[directly modify the bound](#accessing-and-modifying-properties-of-the-bound-1) before using it! --- @@ -1078,6 +1080,368 @@ std::cout << "Distance between Chebyshev distance BallBound and " --- +### `HollowBallBound` + +The `HollowBallBound` class represents a bounding shape that is an +arbitrary-dimensional ball bound with another smaller ball subtracted from its +inside. A `HollowBallBound` consists of a center point, an outer radius, and a +secondary center point and inner radius. An example `HollowBallBound` is shown +below in two dimensions; shaded area represents area held within the bound. + +
    +hollow ball bound +
    + +`HollowBallBound` is used directly by the [`VPTree`](vptree.md) class. + +--- + +#### Constructors + +`HollowBallBound` allows configurable behavior via its two template parameters: + +``` +HollowBallBound +``` + +Different constructor forms can be used to specify different template parameters +(and thus different bound behavior). + + * `b = HollowBallBound(dimensionality)` + - Construct a `HollowBallBound` with the given `dimensionality`. + - The bound will be empty with invalid centers and radii (e.g., `b` will not + contain any points at all). + - The bound will use the [Euclidean distance](../distances.md#lmetric) for + distance computation, and will expect data to have elements with type + `double`. + + * `b = HollowBallBound(dimensionality)` + - Construct a `HollowBallBound` with the given `dimensionality` that will use + the given `DistanceType` class to compute distances, and expect data to + have elements with type `ElemType`. + - `ElemType` should generally be `double` or `float`. + +***Note***: these constructors provide an empty bound; be sure to +[grow](#growing-the-bound-1) the bound or +[directly modify the bound](#accessing-and-modifying-properties-of-the-bound-2) +before using it! + +--- + + * `b = HollowBallBound(innerRadius, outerRadius, center)` + - Construct a `HollowBallBound` with the given `innerRadius` for the inner + ball, `outerRadius` for the outer ball, and `center`. + - Both the inner and outer ball are centered at `center`. + - `innerRadius` and `outerRadius` should have type `double`. + - `center` should have type `arma::vec`. + - The bound will use the [Euclidean distance](../distances.md#lmetric) for + distance computation, and will expect data to have elements with type + `double`. + + * `b = HollowBallBound(innerRadius, outerRadius, center)` + - Construct a `HollowBallBound` with the given `innerRadius` for the inner + ball, `outerRadius` for the outer ball, and `center`. + - Both the inner and outer ball are centered at `center`. + - `innerRadius` and `outerRadius` should have type `ElemType`. + - `center` should be a vector with element type `ElemType` (e.g. + `arma::Col`). + - The bound will use the given `DistanceType` class to compute distances, and + expect data to have elements with type `ElemType`. + +--- + +#### Accessing and modifying properties of the bound + +The individual bounds associated with each dimension of a `HollowBallBound` can +be accessed and modified. + + * `b.Dim()` will return a `size_t` indicating the dimensionality of the bound. + + * `b.Center()` returns an `arma::vec&` containing the center of the outer ball. + Its elements can be directly modified. + + * `b.HollowCenter()` returns an `arma::vec&` containing the center of the inner + ball. Its elements can be directly modified. + - It is possible that `b.HollowCenter()` is outside of the outer ball! + + * `b.OuterRadius()` will return a `double` that is the radius of the outer + ball. + - `b.OuterRadius() = r` will set the radius of the outer ball to `r`. + + * `b.InnerRadius()` will return a `double` that is the radius of the inner + ball. + - `b.InnerRadius() = r` will set the radius of the inner ball to `r`. + - It is possible that `b.InnerRadius() > b.OuterRadius()`, and this implies + that the hollow center is outside the outer ball (otherwise the bound is + empty). + + * `b[dim]` will return a [`Range`](../math.md#range) object representing the + extents of the bound in dimension `dim`. + - The range is defined as + `[b.Center()[dim] - b.OuterRadius(), b.Center()[dim] + b.OuterRadius()]`. + - ***Note:*** this returns the maximum extents of the bound and does not + consider the inner (hollow) ball. + + * `b.Diameter()` returns the diameter of the ball. This is always equal to + `2 * b.OuterRadius()`. + + * `b.MinWidth()` returns the minimum width of the bound in any dimension as a + `double`. This is always equal to `b.Diameter()`. + + * `b.Distance()` returns either a + [`EuclideanDistance`](../distances.md#lmetric) distance metric object, or a + `DistanceType` if a custom `DistanceType` has been specified in the + constructor. + + * `b.Center(center)` will store the center of the `HollowBallBound` in the + vector `center`. `center` should be of type `arma::vec`. + + * `b.MinWidth()` returns the minimum width of the bound in any dimension as a + `double`. This value is cached and no computation is performed when calling + `b.MinWidth()`. If the bound is empty, `0` is returned. + + * `b.Distance()` returns either a + [`EuclideanDistance`](../distances.md#lmetric) distance metric object, or a + `DistanceType` if a custom `DistanceType` has been specified in the + constructor. + + * `b.Center(center)` will compute the center of the `HollowBallBound` (e.g. the + vector with elements equal to the midpoint of `b` in each dimension) and + store it in the vector `center`. `center` should be of type `arma::vec`. + + * `b.Volume()` computes the volume of the hyperrectangle specified by `b`. The + volume is returned as a `double`. + + * `b.Diameter()` computes the longest diagonal of the hyperrectangle specified + by `b`. + + * A `HollowBallBound` can be serialized with + [`data::Save()` and `data::Load()`](../../load_save.md#mlpack-objects). + +***Note:*** if a custom `ElemType` was specified in the constructor, then: + + * `b[dim]` will return a `RangeType`; + * `b.OuterRadius()`, `b.InnerRadius()`, `b.MinWidth()`, and `b.Diameter()` will + return `ElemType`; + * `b.Center()` and `b.HollowCenter()` will return `arma::Col&`; and + * `b.Center(center)` expects `center` to be of type `arma::Col`. + +--- + +#### Growing the bound + +The `HollowBallBound` uses the logical `|=` to grow the bound to include points +or other bounds. + + * `b |= data` expands `b` so the outer ball includes all of the data points in + `data`, shrinking the inner ball as necessary. `data` should be a + [column-major `arma::mat`](../../matrices.md#representing-data-in-mlpack). + The expansion operation is minimal, so `b` is not expanded any more than + necessary. + - The bound is grown using [Jack Ritter's bounding sphere + algorithm](https://en.wikipedia.org/wiki/Bounding_sphere#Ritter's_bounding_sphere), + which may move the center of the bound as it iteratively adds points to the + bound. (The hollow center is not moved.) + - If the bound is empty, the centers are initialized to the first point of + `data`. + - If the bound is not empty, then `data` is expected to have dimensionality + that matches `b.Dim()`. + + * `b |= bound` expands `b` to include all of the volume included in `bound`. + The center points will not be modified. + - The outer ball's radius will be expanded to include the outer balls of both + `b` and `bound`. + - The inner (hollow) ball's radius will be shrunk to be the intersection of + the inner balls of `b` and `bound`. (This may result in `b.InnerRadius()` + being 0.) + +***Notes:*** + + - The growth operation does not grow the inner (hollow) ball. Properties + related to the inner ball should be set manually with `b.HollowCenter()` and + `b.InnerRadius()`. + + - If a custom `ElemType` was specified, then any `data` argument should be a + matrix with that `ElemType` (e.g. `arma::Mat`). + +--- + +#### Bounding distances to other objects + +Once a `HollowBallBound` has been successfully created and set to the desired +bounding balls, there are a number of functions that can bound the +distance between a `HollowBallBound` and other objects. + + * `b.Contains(point)` + * `b.Contains(bound)` + - Return a `bool` indicating whether or not `b` contains the given `point` + (an `arma::vec`) or another `bound` (an `HRectBound`). + - When passing another `bound`, `true` will be returned if `bound` even + partially overlaps with `b`. + + * `b.MinDistance(point)` + * `b.MinDistance(bound)` + - Return a `double` whose value is the minimum possible distance between `b` + and either a `point` (an `arma::vec`) or another `bound` (a + `HollowBallBound`). + - The minimum distance between `b` and another point or bound is the length + of the shortest possible line that can connect the other point or bound to + `b`. + - If `point` or `bound` are contained in `b`, then the returned distance is + 0. + + * `b.MaxDistance(point)` + * `b.MaxDistance(bound)` + - Return a `double` whose value is the maximum possible distance between `b` + and either a `point` (an `arma::vec`) or another `bound` (a + `HollowBallBound`). + - The maximum distance between `b` and a given `point` is the furthest + possible distance between `point` and any possible point falling within the + bounding hyperrectangle of `b`. + - The maximum distance between `b` and another `bound` is the furthest + possible distance between any possible point falling within the bounding + hyperrectangle of `b`, and any possible point falling within the bounding + hyperrectangle of `bound`. + - Note that this definition means that even if `b.Contains(point)` or + `b.Contains(bound)` is `true`, the maximum distance may be greater than + `0`. + + * `b.RangeDistance(point)` + * `b.RangeDistance(bound)` + - Compute the minimum and maximum distance between `b` and `point` or + `bound`, returning the result as a [`Range`](../math.md#range) object. + - This is more efficient than calling `b.MinDistance()` and + `b.MaxDistance()`. + +***Note:*** if a custom `DistanceType` and `ElemType` were specified in the +constructor, then all distances will be computed with respect to the specified +`DistanceType` and all return values will either be `ElemType` or +[`RangeType`](../math.md#range) (except for `Contains()`, which will +still return a `bool`). + +--- + +#### Example usage + +```c++ +// Create a hollow ball bound in 3 dimensions whose outer ball is the unit ball +// and whose inner ball is the ball with radius 0.5 centered at the origin. +// The bounding range for all three dimensions is [0.0, 1.0]. +mlpack::HollowBallBound b(0.5, 1.0, arma::vec(3)); + +std::cout << "Hollow unit ball bound created manually:" << std::endl; +std::cout << " - Center: " << b.Center().t(); +std::cout << " - Outer radius: " << b.OuterRadius() << "." << std::endl; +std::cout << " - Hollow center: " << b.HollowCenter().t(); +std::cout << " - Inner radius: " << b.InnerRadius() << "." << std::endl; +for (size_t i = 0; i < 3; ++i) +{ + std::cout << " - Dimension " << i << " extents: [" << b[i].Lo() << ", " + << b[i].Hi() << "]." << std::endl; +} +std::cout << std::endl; + +// Create a small dataset of 5 points. +arma::mat dataset(3, 5); +dataset.col(0) = arma::vec("2.0 2.0 2.0"); +dataset.col(1) = arma::vec("2.5 2.5 2.5"); +dataset.col(2) = arma::vec("3.0 2.0 3.0"); +dataset.col(3) = arma::vec("2.0 3.0 2.0"); +dataset.col(4) = arma::vec("3.0 3.0 3.0"); + +// If we simply build a HollowBallBound to enclose those points, the hollow part +// of the ball is unmodified and remains empty. +mlpack::HollowBallBound b2(3); +b2 |= dataset; +std::cout << "Hollow ball bound on points with only `operator|=()`:" + << std::endl; +std::cout << " - Center: " << b2.Center().t(); +std::cout << " - Outer radius: " << b2.OuterRadius() << "." << std::endl; +std::cout << " - Hollow center: " << b2.HollowCenter().t(); +std::cout << " - Inner radius: " << b2.InnerRadius() << "." << std::endl; +std::cout << std::endl; + +// On the other hand, if we initialize a HollowBallBound to a non-empty bound, +// then `operator|=()` will shrink the hollow ball as necessary. +// +// We initialize this ball bound to a "slice" with radii [3.6, 3.7]. +mlpack::HollowBallBound b3(3.6, 3.7, arma::vec(3)); +b3 |= dataset; +std::cout << "Hollow ball bound on points with pre-initialization and " + << "`operator|=()`:" << std::endl; +std::cout << " - Center: " << b3.Center().t(); +std::cout << " - Outer radius: " << b3.OuterRadius() << "." << std::endl; +std::cout << " - Hollow center: " << b3.HollowCenter().t(); +std::cout << " - Inner radius: " << b3.InnerRadius() << "." << std::endl; +std::cout << std::endl; + +// Manually create a hollow ball bound whose hollow center is different than the +// outer ball's center. +mlpack::HollowBallBound b4(3); +b4.OuterRadius() = 3.0; +b4.InnerRadius() = 1.5; +b4.Center() = arma::vec(3); +b4.HollowCenter() = arma::vec("1.0 1.0 1.0"); + +// Compute the minimum distance between a point inside the hollow unit ball's +// outer ball. +const double d1 = b.MinDistance(arma::vec("0.9 0.9 0.9")); +std::cout << "Minimum distance between hollow unit ball bound and [0.9, 0.9, " + << "0.9]: " << d1 << "." << std::endl; + +// Compute the minimum distance between a point inside the hollow unit ball's +// inner ball (so the point is not contained in the bound---it is within the +// hollow section). +const double d2 = b.MinDistance(arma::vec("0.0 0.0 0.0")); +std::cout << "Minimum distance between hollow unit ball bound and [0.0, 0.0, " + << "0.0]: " << d2 << "." << std::endl; +std::cout << std::endl; + +// Use Contains(). In this case, the 'else' will be taken. +if (b.Contains(arma::vec("1.5 1.5 1.5"))) +{ + std::cout << "Hollow unit ball bound contains [1.5, 1.5, 1.5]." << std::endl; +} +else +{ + std::cout << "Hollow unit ball bound does not contain [1.5, 1.5, 1.5]." + << std::endl; +} +std::cout << std::endl; + +// Compute the maximum distance between a point inside the unit ball and the +// unit hollow ball bound. +const double d3 = b4.MaxDistance(arma::vec("0.1 0.1 0.1")); +std::cout << "Maximum distance between hollow unit ball bound and [0.1, 0.1, " + << "0.1]: " << d3 << "." << std::endl; + +// Compute the minimum and maximum distances between the hollow unit ball bound +// and the bound built on data points. +const mlpack::Range r = b.RangeDistance(b3); +std::cout << "Distances between hollow unit ball bound and second hollow " + << "dataset bound: [" << r.Lo() << ", " << r.Hi() << "]." << std::endl; + +// Create a bound using the Manhattan (L1) distance and compute the minimum and +// maximum distance to a point. +mlpack::HollowBallBound mb(2.0, 5.0, arma::vec(3)); +const mlpack::Range r2 = mb.RangeDistance(arma::vec("1.5 1.5 4.0")); +std::cout << "Distance between Manhattan distance HollowBallBound and " + << "[1.5, 1.5, 4.0]: [" << r2.Lo() << ", " << r2.Hi() << "]." << std::endl; + +// Create a bound using the Chebyshev (L-inf) distance, using random 32-bit +// floating point elements, and compute the minimum and maximum distance to a +// point. +arma::fmat floatData(3, 25, arma::fill::randu); +mlpack::HollowBallBound cb; +cb |= floatData; +// Note the use of arma::fvec to represent a point, since ElemType is float. +const mlpack::RangeType r3 = cb.RangeDistance(arma::fvec("1.5 1.5 4.0")); +std::cout << "Distance between Chebyshev distance HollowBallBound and " + << "[1.5, 1.5, 4.0]: [" << r3.Lo() << ", " << r3.Hi() << "]." << std::endl; +``` + +--- + ### Custom `BoundType`s The `BinarySpaceTree` class allows an arbitrary `BoundType` template parameter @@ -1261,6 +1625,8 @@ to write a fully custom split: with maximum width * [`MeanSplit`](#meansplit): splits on the mean value of the points in the dimension with maximum width + * [`VantagePointSplit`](#vantagepointsplit): split by selecting a 'vantage + point' and then split points into 'near' and 'far' sets * [`RPTreeMeanSplit`](#rptreemeansplit): projects points onto a random vector, splitting on the median value of the projections, or in some cases on the distance from the mean value @@ -1314,6 +1680,51 @@ task*. For implementation details, see [the source code](/src/mlpack/core/tree/binary_space_tree/mean_split_impl.hpp). +### `VantagePointSplit` + +The `VantagePointSplit` class is a splitting strategy that can be used by +[`BinarySpaceTree`](#binaryspacetree). It is the default strategy for splitting +[`VPTree`s](vptree.md), and is detailed in +[the paper](https://www.mlpack.org/papers/uhlmann91.pdf). +Due to the nature of the split, ***`VantagePointSplit` should always be used +with the [`HollowBallBound`](#hollowballbound)***. + +The splitting strategy for the `VantagePointSplit` class is, given a set of +points: + + * Select a vantage point from a sample of 100 random candidate points (or use + the full set if there are fewer than 100 points): + - Compute the distances between each candidate point and 100 additional + random samples (or the full set if there are fewer than 100 points). + - Select the vantage point as the candidate with maximum average distance to + the additional random samples. + * Compute a boundary distance `mu` that is the median distance between the + vantage point and its random samples. + * Points with distance less than `mu` from the vantage point will go to the + left child. + * Points with distance greater than `mu` from the vantage point will go to the + right child. + +The `VantagePointSplit` class has three template parameters: + +``` +VantagePointSplit +``` + +If a custom number of samples `S` is desired, the easiest way to specify is via +a template typedef: + +``` +template +using MyVantagePointSplit = VantagePointSplit; +``` + +Then, `MyVantagePointSplit` can be used directly with `BinarySpaceTree` as a +`SplitType`. + +For implementation details, see +[the source code](/src/mlpack/core/tree/binary_space_tree/vantage_point_split_impl.hpp). + ### `RPTreeMeanSplit` The `RPTreeMeanSplit` class is a splitting strategy that can be used by diff --git a/doc/user/core/trees/vptree.md b/doc/user/core/trees/vptree.md new file mode 100644 index 0000000000..b0b916651d --- /dev/null +++ b/doc/user/core/trees/vptree.md @@ -0,0 +1,634 @@ +# `VPTree` + + + +The `VPTree` class represents a `k`-dimensional vantage point tree, +and is a well-known data structure for efficient distance operations (such as +nearest neighbor search) in low dimensions---typically less than 100. The +vantage point tree is also known as the 'metric tree'. + +A vantage point tree is a binary tree where each node selects a 'vantage +point', and child nodes partition points into those that are nearer to the +vantage point and those that are further from it. `VPTree` supports arbitrary +[distance metrics](../distances.md) that are not +[`LMetric`](../distances.md#lmetric), making it more flexible than `KDTree`. + +mlpack's `VPTree` implementation supports three template parameters for +configurable behavior, and implements all the functionality required by the +[TreeType API](../../../developer/trees.md#the-treetype-api), plus some +additional functionality specific to vantage point trees. + + * [Template parameters](#template-parameters) + * [Constructors](#constructors) + * [Basic tree properties](#basic-tree-properties) + * [Bounding distances with the tree](#bounding-distances-with-the-tree) + * [Tree traversals](#tree-traversals) + * [Example usage](#example-usage) + +## See also + + + + * [Vantage point tree on Wikipedia](https://en.wikipedia.org/wiki/Vantage-point_tree) + * [`BinarySpaceTree`](binary_space_tree.md) + * [Binary space partitioning on Wikipedia](https://dl.acm.org/doi/pdf/10.1145/361002.361007) + * [Data structures and algorithms for nearest neighbor search in general metric spaces (pdf)](https://dl.acm.org/doi/pdf/10.5555/313559.313789) + * [Satisfying General Proximity/Similarity Queries with Metric Trees (pdf)](https://www.mlpack.org/papers/uhlmann91.pdf) + * [Tree-Independent Dual-Tree Algorithms (pdf)](https://www.ratml.org/pub/pdf/2013tree.pdf) + +## Template parameters + +In accordance with the [TreeType +API](../../../developer/trees.md#template-parameters-required-by-the-treetype-policy) +(see also [this more detailed section](../../../developer/trees.md#template-parameters)), +the `VPTree` class takes three template parameters: + +``` +VPTree +``` + + * `DistanceType`: the [distance metric](../distances.md) to use for distance + computations. By default, this is + [`EuclideanDistance`](../distances.md#lmetric). + * [`StatisticType`](binary_space_tree.md#statistictype): this holds auxiliary + information in each tree node. By default, + [`EmptyStatistic`](binary_space_tree.md#emptystatistic) is used, which holds + no information. + * `MatType`: the type of matrix used to represent points. Must be a type + matching the [Armadillo API](../../matrices.md). By default, `arma::mat` is + used, but other types such as `arma::fmat` or similar will work just fine. + +The `VPTree` class itself is a convenience typedef of the generic +[`BinarySpaceTree`](binary_space_tree.md) class, using the +[`HollowBallBound`](binary_space_tree.md#hollowballbound) class as the bounding +structure, and using the +[`VantagePointSplit`](binary_space_tree.md#vantagepointsplit) splitting strategy +for construction, which splits points into those that are nearer and further +from a 'vantage point'. + +## Constructors + +`VPTree`s are efficiently constructed by permuting points in a dataset in a +quicksort-like algorithm. However, this means that the ordering of points in +the tree's dataset (accessed with `node.Dataset()`) after construction may be +different. + +--- + + * `node = VPTree(data, maxLeafSize=20)` + * `node = VPTree(data, oldFromNew, maxLeafSize=20)` + * `node = VPTree(data, oldFromNew, newFromOld, maxLeafSize=20)` + - Construct a `VPTree` on the given `data`, using `maxLeafSize` as the + maximum number of points held in a leaf. + - By default, `data` is copied. Avoid a copy by using `std::move()` (e.g. + `std::move(data)`); when doing this, `data` will be set to an empty matrix. + - Optionally, construct mappings from old points to new points. `oldFromNew` + and `newFromOld` will have length `data.n_cols`, and: + * `oldFromNew[i]` indicates that point `i` in the tree's dataset was + originally point `oldFromNew[i]` in `data`; that is, + `node.Dataset().col(i)` is the point `data.col(oldFromNew[i])`. + * `newFromOld[i]` indicates that point `i` in `data` is now point + `newFromOld[i]` in the tree's dataset; that is, + `node.Dataset().col(newFromOld[i])` is the point `data.col(i)`. + +--- + + * `node = VPTree(data, maxLeafSize=20)` + * `node = VPTree(data, oldFromNew, maxLeafSize=20)` + * `node = VPTree(data, oldFromNew, newFromOld, maxLeafSize=20)` + - Construct a `VPTree` on the given `data`, using custom template parameters + to control the behavior of the tree, using `maxLeafSize` as the maximum + number of points held in a leaf. + - By default, `data` is copied. Avoid a copy by using `std::move()` (e.g. + `std::move(data)`); when doing this, `data` will be set to an empty matrix. + - Optionally, construct mappings from old points to new points. `oldFromNew` + and `newFromOld` will have length `data.n_cols`, and: + * `oldFromNew[i]` indicates that point `i` in the tree's dataset was + originally point `oldFromNew[i]` in `data`; that is, + `node.Dataset().col(i)` is the point `data.col(oldFromNew[i])`. + * `newFromOld[i]` indicates that point `i` in `data` is now point + `newFromOld[i]` in the tree's dataset; that is, + `node.Dataset().col(newFromOld[i])` is the point `data.col(i)`. + +--- + + * `node = VPTree()` + - Construct an empty vantage point tree with no children and no points. + +--- + +***Notes:*** + + - The name `node` is used here for `VPTree` objects instead of `tree`, because + each `VPTree` object is a single node in the tree. The constructor returns + the node that is the root of the tree. + + - Inserting individual points or removing individual points from a `VPTree` is + not supported, because this generally results in a vantage point tree with + very loose bounding balls. It is better to simply build a new `VPTree` on + the modified dataset. For trees that support individual insertion and + deletions, see the `RectangleTree` class and all its variants (e.g. `RTree`, + `RStarTree`, etc.). + + - See also the + [developer documentation on tree constructors](../../../developer/trees.md#constructors-and-destructors). + + + +--- + +### Constructor parameters: + +| **name** | **type** | **description** | **default** | +|----------|----------|-----------------|-------------| +| `data` | [`arma::mat`](../../matrices.md) | [Column-major](../../matrices.md#representing-data-in-mlpack) matrix to build the tree on. Pass with `std::move(data)` to avoid copying the matrix. | _(N/A)_ | +| `maxLeafSize` | `size_t` | Maximum number of points to store in each leaf. | `20` | +| `oldFromNew` | `std::vector` | Mappings from points in `node.Dataset()` to points in `data`. | _(N/A)_ | +| `newFromOld` | `std::vector` | Mappings from points in `data` to points in `node.Dataset()`. | _(N/A)_ | + +## Basic tree properties + +Once a `VPTree` object is constructed, various properties of the tree can be +accessed or inspected. Many of these functions are required by the [TreeType +API](../../../developer/trees.md#the-treetype-api). + +### Navigating the tree + + * `node.NumChildren()` returns the number of children in `node`. This is + either `2` if `node` has children, or `0` if `node` is a leaf. + + * `node.IsLeaf()` returns a `bool` indicating whether or not `node` is a leaf. + + * `node.Child(i)` returns a `VPTree&` that is the `i`th child. + - `i` must be `0` or `1`. + - This function should only be called if `node.NumChildren()` is not `0` + (e.g. if `node` is not a leaf). Note that this returns a valid `VPTree&` + that can itself be used just like the root node of the tree! + - `node.Left()` and `node.Right()` are convenience functions specific to + `VPTree` that will return `VPTree*` (pointers) to the left and right + children, respectively, or `NULL` if `node` has no children. + + * `node.Parent()` will return a `VPTree*` that points to the parent of `node`, + or `NULL` if `node` is the root of the `VPTree`. + +--- + +### Accessing members of a tree + + * `node.Bound()` will return an + [`HollowBallBound&`](binary_space_tree.md#hollowballbound) object that + represents the hollow bounding ball of `node`. This structure encloses all + the descendant points of `node`. + + * `node.Stat()` will return an `EmptyStatistic&` (or a `StatisticType&` if a + [custom `StatisticType`](#template-parameters) was specified as a template + parameter) holding the statistics of the node that were computed during tree + construction. + + * `node.Distance()` will return a + [`EuclideanDistance&`](../distances.md#lmetric) (or a `DistanceType&` if a + [custom `DistanceType`](#template-parameters) was specified as a template + parameter). + +See also the +[developer documentation](../../../developer/trees.md#basic-tree-functionality) +for basic tree functionality in mlpack. + +--- + +### Accessing data held in a tree + + * `node.Dataset()` will return a `const arma::mat&` that is the dataset the + tree was built on. Note that this is a permuted version of the `data` matrix + passed to the constructor. + - If a [custom `MatType`](#template-parameters) is being used, the return + type will be `const MatType&` instead of `const arma::mat&`. + + * `node.NumPoints()` returns a `size_t` indicating the number of points held + directly in `node`. + - If `node` is not a leaf, this will return `0`, as `VPTree` only holds + points directly in its leaves. + - If `node` is a leaf, then the number of points will be less than or equal + to the `maxLeafSize` that was specified when the tree was constructed. + + * `node.Point(i)` returns a `size_t` indicating the index of the `i`'th point + in `node.Dataset()`. + - `i` must be in the range `[0, node.NumPoints() - 1]` (inclusive). + - `node` must be a leaf (as non-leaves do not hold any points). + - The `i`'th point in `node` can then be accessed as + `node.Dataset().col(node.Point(i))`. + - In a `VPTree`, because of the permutation of points done [during + construction](#constructors), point indices are contiguous: + `node.Point(i + j)` is the same as `node.Point(i) + j` for valid `i` and + `j`. + - Accessing the actual `i`'th point itself can be done with, e.g., + `node.Dataset().col(node.Point(i))`. + + * `node.NumDescendants()` returns a `size_t` indicating the number of points + held in all descendant leaves of `node`. + - If `node` is the root of the tree, then `node.NumDescendants()` will be + equal to `node.Dataset().n_cols`. + + * `node.Descendant(i)` returns a `size_t` indicating the index of the `i`'th + descendant point in `node.Dataset()`. + - `i` must be in the range `[0, node.NumDescendants() - 1]` (inclusive). + - `node` does not need to be a leaf. + - The `i`'th descendant point in `node` can then be accessed as + `node.Dataset().col(node.Descendant(i))`. + - In a `VPTree`, because of the permutation of points done [during + construction](#constructors), point indices are contiguous: + `node.Descendant(i + j)` is the same as `node.Descendant(i) + j` for valid + `i` and `j`. + - Accessing the actual `i`'th descendant itself can be done with, e.g., + `node.Dataset().col(node.Descendant(i))`. + + * `node.Begin()` returns a `size_t` indicating the index of the first + descendant point of `node`. + - This is equivalent to `node.Descendant(0)`. + + * `node.Count()` returns a `size_t` indicating the number of descendant points of `node`. + - This is equivalent to `node.NumDescendants()`. + +--- + +### Accessing computed bound quantities of a tree + +The following quantities are cached for each node in a `VPTree`, and so +accessing them does not require any computation. + + * `node.FurthestPointDistance()` returns a `double` representing the distance + between the center of the hollow bounding ball of `node` and the furthest + point held by `node`. + - If `node` is not a leaf, this returns 0 (because `node` does not hold any + points). + + * `node.FurthestDescendantDistance()` returns a `double` representing the + distance between the center of the hollow bounding ball of `node` and the + furthest descendant point held by `node`. + + * `node.MinimumBoundDistance()` returns a `double` representing minimum + possible distance from the center of the node to any edge of the + hollow ball bound. + - This quantity is equivalent to `node.Bound().OuterRadius()`. + + * `node.ParentDistance()` returns a `double` representing the distance between + the center of the hollow bounding ball of `node` and the center of the + hollow bounding ball of its parent. + - If `node` is the root of the tree, `0` is returned. + +***Notes:*** + + - If a [custom `MatType`](#template-parameters) was specified when constructing + the `VPTree`, then the return type of each method is the element type of the + given `MatType` instead of `double`. (e.g., if `MatType` is `arma::fmat`, + then the return type is `float`.) + + - For more details on each bound quantity, see the + [developer documentation](../../../developer/trees.md#complex-tree-functionality-and-bounds) + on bound quantities for trees. + +--- + +### Other functionality + + * `node.Center(center)` computes the center of the hollow bounding ball of + `node` and stores it in `center`. + - `center` should be of type `arma::vec&`. (If a [custom + `MatType`](#template-parameters) was specified when constructing the + `VPTree`, the type is instead the column vector type for the given + `MatType`; e.g., `arma::fvec&` when `MatType` is `arma::fmat`.) + - `center` will be set to have size equivalent to the dimensionality of the + dataset held by `node`. + - This is equivalent to calling `node.Bound().Center(center)`. + + * A `VPTree` can be serialized with + [`data::Save()` and `data::Load()`](../../load_save.md#mlpack-objects). + +## Bounding distances with the tree + +The primary use of trees in mlpack is bounding distances to points or other tree +nodes. The following functions can be used for these tasks. + + * `node.GetNearestChild(point)` + * `node.GetFurthestChild(point)` + - Return a `size_t` indicating the index of the child (`0` for left, `1` for + right) that is closest to (or furthest from) `point`, with respect + to the `MinDistance()` (or `MaxDistance()`) function. + - If there is a tie, `0` (the left child) is returned. + - If `node` is a leaf, `0` is returned. + - `point` should be of type `arma::vec`. (If a [custom + `MatType`](#template-parameters) was specified when constructing the + `VPTree`, the type is instead the column vector type for the given + `MatType`; e.g., `arma::fvec` when `MatType` is `arma::fmat`.) + + * `node.GetNearestChild(other)` + * `node.GetFurthestChild(other)` + - Return a `size_t` indicating the index of the child (`0` for left, `1` for + right) that is closest to (or furthest from) the `VPTree` node `other`, + with respect to the `MinDistance()` (or `MaxDistance()`) function. + - If there is a tie, `2` (an invalid index) is returned. ***Note that this + behavior differs from the version above that takes a point.*** + - If `node` is a leaf, `0` is returned. + +--- + + * `node.MinDistance(point)` + * `node.MinDistance(other)` + - Return a `double` indicating the minimum possible distance between `node` + and `point`, or the `VPTree` node `other`. + - This is equivalent to the minimum possible distance between any point + contained in the hollow bounding ball of `node` and `point`, or between + any point contained in the hollow bounding ball of `node` and any point + contained in the hollow bounding ball of `other`. + - `point` should be of type `arma::vec`. (If a [custom + `MatType`](#template-parameters) was specified when constructing the + `VPTree`, the type is instead the column vector type for the given + `MatType`, and the return type is the element type of `MatType`; e.g., + `point` should be `arma::fvec` when `MatType` is `arma::fmat`, and the + returned distance is `float`). + + * `node.MaxDistance(point)` + * `node.MaxDistance(other)` + - Return a `double` indicating the maximum possible distance between `node` + and `point`, or the `VPTree` node `other`. + - This is equivalent to the maximum possible distance between any point + contained in the hollow bounding ball of `node` and `point`, or between + any point contained in the hollow bounding ball of `node` and any point + contained in the hollow bounding ball of `other`. + - `point` should be of type `arma::vec`. (If a [custom + `MatType`](#template-parameters) was specified when constructing the + `VPTree`, the type is instead the column vector type for the given + `MatType`, and the return type is the element type of `MatType`; e.g., + `point` should be `arma::fvec` when `MatType` is `arma::fmat`, and the + returned distance is `float`). + + * `node.RangeDistance(point)` + * `node.RangeDistance(other)` + - Return a [`Range`](../math.md#range) whose lower bound is + `node.MinDistance(point)` or `node.MinDistance(other)`, and whose upper + bound is `node.MaxDistance(point)` or `node.MaxDistance(other)`. + - `point` should be of type `arma::vec`. (If a + [custom `MatType`](#template-parameters) was specified when constructing + the `VPTree`, the type is instead the column vector type for the given + `MatType`, and the return type is a `RangeType` with element type the same + as `MatType`; e.g., `point` should be `arma::fvec` when `MatType` is + `arma::fmat`, and the returned type is + [`RangeType`](../math.md#range)). + +### Tree traversals + +Like every mlpack tree, the `VPTree` class provides a [single-tree and dual-tree +traversal](../../../developer/trees.md#traversals) that can be paired with a +[`RuleType` class](../../../developer/trees.md#rules) to implement a single-tree +or dual-tree algorithm. + + * `VPTree::SingleTreeTraverser` + - Implements a depth-first single-tree traverser. + + * `VPTree::DualTreeTraverser` + - Implements a dual-depth-first dual-tree traverser. + +In addition to those two classes, which are required by the +[`TreeType` policy](../../../developer/trees.md), an additional traverser is +available: + + * `VPTree::BreadthFirstDualTreeTraverser` + - Implements a dual-breadth-first dual-tree traverser. + - ***Note:*** this traverser is not useful for all tasks; because the + `VPTree` only holds points in the leaves, this means that no base cases + (e.g. comparisons between points) will be called until *all* pairs of + intermediate nodes have been scored! + +## Example usage + +Build a `VPTree` on the `cloud` dataset and print basic statistics about the +tree. + +```c++ +// See https://datasets.mlpack.org/cloud.csv. +arma::mat dataset; +mlpack::data::Load("cloud.csv", dataset, true); + +// Build the vp-tree with a leaf size of 10. (This means that nodes are split +// until they contain 10 or fewer points.) +// +// The std::move() means that `dataset` will be empty after this call, and no +// data will be copied during tree building. +// +// Note that the '<>' isn't necessary if C++20 is being used (e.g. +// `mlpack::VPTree tree(...)` will work fine in C++20 or newer). +mlpack::VPTree<> tree(std::move(dataset)); + +// Print the bounding ball of the root node. (There will be no hollow ball.) +std::cout << "Bounding ball of root node:" << std::endl; +std::cout << " - Center: " << tree.Bound().Center().t(); +std::cout << " - Outer radius: " << tree.Bound().OuterRadius() << "." + << std::endl; +std::cout << " - Hollow center: " << tree.Bound().HollowCenter().t(); +std::cout << " - Inner radius: " << tree.Bound().InnerRadius() << "." + << std::endl; +std::cout << std::endl; + +// Print the bounding ball of the right child. (This will have a hollow ball.) +std::cout << "Bounding ball of right child: " << std::endl; +std::cout << " - Center: " << tree.Right()->Bound().Center().t(); +std::cout << " - Outer radius: " << tree.Right()->Bound().OuterRadius() << "." + << std::endl; +std::cout << " - Hollow center: " << tree.Right()->Bound().HollowCenter().t(); +std::cout << " - Inner radius: " << tree.Right()->Bound().InnerRadius() << "." + << std::endl; +std::cout << " - Distance between centers: " << +mlpack::EuclideanDistance::Evaluate(tree.Right()->Bound().Center(), +tree.Right()->Bound().HollowCenter()) << "." << std::endl; +std::cout << std::endl; + +// Print the number of descendant points of the root, and of each of its +// children. +std::cout << "Descendant points of root: " + << tree.NumDescendants() << "." << std::endl; +std::cout << "Descendant points of left child: " + << tree.Left()->NumDescendants() << "." << std::endl; +std::cout << "Descendant points of right child: " + << tree.Right()->NumDescendants() << "." << std::endl; +std::cout << std::endl; + +// Print the center of the vp-tree. +arma::vec center; +tree.Center(center); +std::cout << "Center of vp-tree: " << center.t(); +``` + +--- + +Build two `VPTree`s on subsets of the corel dataset and compute various +bounding quantities. + +```c++ +// See https://datasets.mlpack.org/corel-histogram.csv. +arma::mat dataset; +mlpack::data::Load("corel-histogram.csv", dataset, true); + +// Build vp-trees on the first half and the second half of points. +mlpack::VPTree<> tree1(dataset.cols(0, dataset.n_cols / 2)); +mlpack::VPTree<> tree2(dataset.cols(dataset.n_cols / 2 + 1, + dataset.n_cols - 1)); + +// Compute the maximum distance between the trees. +std::cout << "Maximum distance between tree root nodes: " + << tree1.MaxDistance(tree2) << "." << std::endl; + +// Get the leftmost grandchild of the first tree's root---if it exists. +if (!tree1.IsLeaf() && !tree1.Child(0).IsLeaf()) +{ + mlpack::VPTree<>& node1 = tree1.Child(0).Child(0); + + // Get the rightmost grandchild of the second tree's root---if it exists. + if (!tree2.IsLeaf() && !tree2.Child(1).IsLeaf()) + { + mlpack::VPTree<>& node2 = tree2.Child(1).Child(1); + + // Print the minimum and maximum distance between the nodes. + mlpack::Range dists = node1.RangeDistance(node2); + std::cout << "Possible distances between two grandchild nodes: [" + << dists.Lo() << ", " << dists.Hi() << "]." << std::endl; + + // Print the minimum distance between the first node and the first + // descendant point of the second node. + const size_t descendantIndex = node2.Descendant(0); + const double descendantMinDist = + node1.MinDistance(node2.Dataset().col(descendantIndex)); + std::cout << "Minimum distance between grandchild node and descendant " + << "point: " << descendantMinDist << "." << std::endl; + + // Which child of node2 is closer to node1? + const size_t closerIndex = node2.GetNearestChild(node1); + if (closerIndex == 0) + std::cout << "The left child of node2 is closer to node1." << std::endl; + else if (closerIndex == 1) + std::cout << "The right child of node2 is closer to node1." << std::endl; + else // closerIndex == 2 in this case. + std::cout << "Both children of node2 are equally close to node1." + << std::endl; + + // And which child of node1 is further from node2? + const size_t furtherIndex = node1.GetFurthestChild(node2); + if (furtherIndex == 0) + std::cout << "The left child of node1 is further from node2." + << std::endl; + else if (furtherIndex == 1) + std::cout << "The right child of node1 is further from node2." + << std::endl; + else // furtherIndex == 2 in this case. + std::cout << "Both children of node1 are equally far from node2." + << std::endl; + } +} +``` + +--- + +Build a `VPTree` on 32-bit floating point data and save it to disk. + +```c++ +// See https://datasets.mlpack.org/corel-histogram.csv. +arma::fmat dataset; +mlpack::data::Load("corel-histogram.csv", dataset); + +// Build the VPTree using 32-bit floating point data as the matrix type. +// We will still use the default EmptyStatistic and EuclideanDistance +// parameters. A leaf size of 100 is used here. +mlpack::VPTree tree(std::move(dataset), 100); + +// Save the VPTree to disk with the name 'tree'. +mlpack::data::Save("tree.bin", "tree", tree); + +std::cout << "Saved tree with " << tree.Dataset().n_cols << " points to " + << "'tree.bin'." << std::endl; +``` + +--- + +Load a 32-bit floating point `VPTree` from disk, then traverse it manually and +find the number of leaf nodes with less than 10 children. + +```c++ +// This assumes the tree has already been saved to 'tree.bin' (as in the example +// above). + +// This convenient typedef saves us a long type name! +typedef mlpack::VPTree TreeType; + +TreeType tree; +mlpack::data::Load("tree.bin", "tree", tree); +std::cout << "Tree loaded with " << tree.NumDescendants() << " points." + << std::endl; + +// Recurse in a depth-first manner. Count both the total number of leaves, and +// the number of leaves with less than 10 points. +size_t leafCount = 0; +size_t totalLeafCount = 0; +std::stack stack; +stack.push(&tree); +while (!stack.empty()) +{ + TreeType* node = stack.top(); + stack.pop(); + + if (node->NumPoints() < 10) + ++leafCount; + ++totalLeafCount; + + if (!node->IsLeaf()) + { + stack.push(node->Left()); + stack.push(node->Right()); + } +} + +// Note that it would be possible to use TreeType::SingleTreeTraverser to +// perform the recursion above, but that is more well-suited for more complex +// tasks that require pruning and other non-trivial behavior; so using a simple +// stack is the better option here. + +// Print the results. +std::cout << leafCount << " out of " << totalLeafCount << " leaves have less " + << "than 10 points." << std::endl; +``` + +--- + +Build a `VPTree` and map between original points and new points. + +```c++ +// See https://datasets.mlpack.org/cloud.csv. +arma::mat dataset; +mlpack::data::Load("cloud.csv", dataset, true); + +// Build the tree. +std::vector oldFromNew, newFromOld; +mlpack::VPTree<> tree(dataset, oldFromNew, newFromOld); + +// oldFromNew and newFromOld will be set to the same size as the dataset. +std::cout << "Number of points in dataset: " << dataset.n_cols << "." + << std::endl; +std::cout << "Size of oldFromNew: " << oldFromNew.size() << "." << std::endl; +std::cout << "Size of newFromOld: " << newFromOld.size() << "." << std::endl; +std::cout << std::endl; + +// See where point 42 in the tree's dataset came from. +std::cout << "Point 42 in the permuted tree's dataset:" << std::endl; +std::cout << " " << tree.Dataset().col(42).t(); +std::cout << "Was originally point " << oldFromNew[42] << ":" << std::endl; +std::cout << " " << dataset.col(oldFromNew[42]).t(); +std::cout << std::endl; + +// See where point 7 in the original dataset was mapped. +std::cout << "Point 7 in original dataset:" << std::endl; +std::cout << " " << dataset.col(7).t(); +std::cout << "Mapped to point " << newFromOld[7] << ":" << std::endl; +std::cout << " " << tree.Dataset().col(newFromOld[7]).t(); +``` diff --git a/doc/user/cv.md b/doc/user/cv.md index 53067911d7..51302b57cd 100644 --- a/doc/user/cv.md +++ b/doc/user/cv.md @@ -111,7 +111,7 @@ DecisionTree(MatType&& data, WeightsType&& weights, const size_t minimumLeafSize = 10, const std::enable_if_t::type>::value>* + std::remove_reference_t>::value>* = 0); ``` diff --git a/src/mlpack/bindings/R/default_param.hpp b/src/mlpack/bindings/R/default_param.hpp index 1b39120275..be6fdbf57b 100644 --- a/src/mlpack/bindings/R/default_param.hpp +++ b/src/mlpack/bindings/R/default_param.hpp @@ -26,13 +26,13 @@ namespace r { template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>* = 0, + const std::enable_if_t>>* = 0); /** * Return the default value of a vector option. @@ -40,7 +40,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return the default value of a string option. @@ -48,8 +48,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value - >::type* = 0); + const std::enable_if_t>* = 0); /** * Return the default value of a matrix option, a tuple option, a @@ -59,10 +58,10 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value>::type* /* junk */ = 0); + std::is_same_v>>* /* junk */ = 0); /** * Return the default value of a model option (this returns the default @@ -71,8 +70,8 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Return the default value of an option. This is the function that will be @@ -84,7 +83,7 @@ void DefaultParam(util::ParamData& data, void* output) { std::string* outstr = (std::string*) output; - *outstr = DefaultParamImpl::type>(data); + *outstr = DefaultParamImpl>(data); } } // namespace r diff --git a/src/mlpack/bindings/R/default_param_impl.hpp b/src/mlpack/bindings/R/default_param_impl.hpp index a69a13892f..d210f1c6bd 100644 --- a/src/mlpack/bindings/R/default_param_impl.hpp +++ b/src/mlpack/bindings/R/default_param_impl.hpp @@ -24,15 +24,15 @@ namespace r { template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>*, + const std::enable_if_t>>*) { std::ostringstream oss; - if (std::is_same::value) + if (std::is_same_v) { // If this is the verbose option, print the default that uses the global // package option. @@ -58,13 +58,13 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { // Print each element in an array delimited by square brackets. std::ostringstream oss; const T& vector = std::any_cast(data.value); oss << "c("; - if (std::is_same>::value) + if (std::is_same_v>) { if (vector.size() > 0) { @@ -101,7 +101,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t>*) { const std::string& s = *std::any_cast(&data.value); return "\"" + s + "\""; @@ -114,21 +114,21 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& /* data */, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value>::type* /* junk */) + std::is_same_v>>* /* junk */) { // Get the filename and return it, or return an empty string. - if (std::is_same::value || - std::is_same::value || - std::is_same::value) + if (std::is_same_v || + std::is_same_v || + std::is_same_v) { return "matrix(numeric(), 0, 0)"; } - else if (std::is_same>::value || - std::is_same>::value || - std::is_same>::value) + else if (std::is_same_v> || + std::is_same_v> || + std::is_same_v>) { return "matrix(integer(), 0, 0)"; } @@ -144,8 +144,8 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& /* data */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "NA"; } diff --git a/src/mlpack/bindings/R/get_printable_param.hpp b/src/mlpack/bindings/R/get_printable_param.hpp index e1857855ba..e644113114 100644 --- a/src/mlpack/bindings/R/get_printable_param.hpp +++ b/src/mlpack/bindings/R/get_printable_param.hpp @@ -25,11 +25,11 @@ namespace r { template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { std::ostringstream oss; oss << std::any_cast(data.value); @@ -42,7 +42,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { const T& t = std::any_cast(data.value); @@ -58,7 +58,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // Get the matrix. const T& matrix = std::any_cast(data.value); @@ -74,8 +74,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { std::ostringstream oss; oss << data.cppType << " model at " << std::any_cast(data.value); @@ -88,8 +88,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { // Get the matrix. const T& tuple = std::any_cast(data.value); @@ -116,7 +116,7 @@ void GetPrintableParam(util::ParamData& data, void* output) { *((std::string*) output) = - GetPrintableParam::type>(data); + GetPrintableParam>(data); } } // namespace r diff --git a/src/mlpack/bindings/R/get_printable_type.hpp b/src/mlpack/bindings/R/get_printable_type.hpp index 6ca4932fe1..d04f06f025 100644 --- a/src/mlpack/bindings/R/get_printable_type.hpp +++ b/src/mlpack/bindings/R/get_printable_type.hpp @@ -23,88 +23,85 @@ namespace r { template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if< - !util::IsStdVector::value>::type*, - const typename std::enable_if< - !data::HasSerialize::value>::type*, - const typename std::enable_if< - !arma::is_arma_type::value>::type*, - const typename std::enable_if< - !std::is_same>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t< + !std::is_same_v>>*); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template inline std::string GetPrintableType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); template inline std::string GetPrintableType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); template void GetPrintableType(util::ParamData& d, @@ -112,7 +109,7 @@ void GetPrintableType(util::ParamData& d, void* output) { *((std::string*) output) = - GetPrintableType::type>(d); + GetPrintableType>(d); } } // namespace r diff --git a/src/mlpack/bindings/R/get_printable_type_impl.hpp b/src/mlpack/bindings/R/get_printable_type_impl.hpp index 5dea060aad..9b59da016d 100644 --- a/src/mlpack/bindings/R/get_printable_type_impl.hpp +++ b/src/mlpack/bindings/R/get_printable_type_impl.hpp @@ -22,11 +22,11 @@ namespace r { template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "unknown"; } @@ -34,11 +34,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "integer"; } @@ -46,11 +46,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "numeric"; } @@ -58,15 +58,12 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if< - !util::IsStdVector::value>::type*, - const typename std::enable_if< - !data::HasSerialize::value>::type*, - const typename std::enable_if< - !arma::is_arma_type::value>::type*, - const typename std::enable_if< - !std::is_same>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t< + !std::is_same_v>>*) { return "character"; } @@ -74,11 +71,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "integer"; } @@ -86,11 +83,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "logical"; } @@ -98,9 +95,9 @@ inline std::string GetPrintableType( template inline std::string GetPrintableType( util::ParamData& d, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "vector of " + GetPrintableType(d) + "s"; } @@ -108,17 +105,17 @@ inline std::string GetPrintableType( template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { std::string type = "numeric matrix"; - if (std::is_same::value) + if (std::is_same_v) { if (T::is_row || T::is_col) type = "numeric vector"; } - else if (std::is_same::value) + else if (std::is_same_v) { type = "integer matrix"; if (T::is_row || T::is_col) @@ -131,8 +128,8 @@ inline std::string GetPrintableType( template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return "categorical matrix/data.frame"; } @@ -140,10 +137,10 @@ inline std::string GetPrintableType( template inline std::string GetPrintableType( util::ParamData& d, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { std::string type = util::StripType(d.cppType); if (type == "mlpackModel") diff --git a/src/mlpack/bindings/R/get_r_type.hpp b/src/mlpack/bindings/R/get_r_type.hpp index 3e92bb717d..fdc43beecc 100644 --- a/src/mlpack/bindings/R/get_r_type.hpp +++ b/src/mlpack/bindings/R/get_r_type.hpp @@ -23,11 +23,11 @@ namespace r { template inline std::string GetRType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { return "unknown"; } @@ -35,11 +35,11 @@ inline std::string GetRType( template<> inline std::string GetRType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "logical"; } @@ -47,11 +47,11 @@ inline std::string GetRType( template<> inline std::string GetRType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "integer"; } @@ -59,11 +59,11 @@ inline std::string GetRType( template<> inline std::string GetRType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "integer"; } @@ -71,11 +71,11 @@ inline std::string GetRType( template<> inline std::string GetRType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "numeric"; } @@ -83,15 +83,12 @@ inline std::string GetRType( template<> inline std::string GetRType( util::ParamData& /* d */, - const typename std::enable_if< - !util::IsStdVector::value>::type*, - const typename std::enable_if< - !data::HasSerialize::value>::type*, - const typename std::enable_if< - !arma::is_arma_type::value>::type*, - const typename std::enable_if< - !std::is_same>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t< + !std::is_same_v>>*) { return "character"; } @@ -99,7 +96,7 @@ inline std::string GetRType( template inline std::string GetRType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { return GetRType(d) + " vector"; } @@ -107,9 +104,9 @@ inline std::string GetRType( template inline std::string GetRType( util::ParamData& d, - const typename std::enable_if>::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t>>* = 0, + const std::enable_if_t::value>* = 0) { std::string elemType = GetRType(d); std::string type = "matrix"; @@ -124,8 +121,8 @@ inline std::string GetRType( template inline std::string GetRType( util::ParamData& /* d */, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { return "numeric matrix/data.frame with info"; } @@ -133,8 +130,8 @@ inline std::string GetRType( template inline std::string GetRType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { return util::StripType(d.cppType); } diff --git a/src/mlpack/bindings/R/get_type.hpp b/src/mlpack/bindings/R/get_type.hpp index 55264eedb5..0b62a0cfdc 100644 --- a/src/mlpack/bindings/R/get_type.hpp +++ b/src/mlpack/bindings/R/get_type.hpp @@ -24,11 +24,11 @@ namespace r { template inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { return "unknown"; } @@ -36,11 +36,11 @@ inline std::string GetType( template<> inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "Int"; } @@ -48,11 +48,11 @@ inline std::string GetType( template<> inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "Float"; } @@ -60,11 +60,11 @@ inline std::string GetType( template<> inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "Double"; } @@ -72,14 +72,11 @@ inline std::string GetType( template<> inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if< - !util::IsStdVector::value>::type*, - const typename std::enable_if< - !data::HasSerialize::value>::type*, - const typename std::enable_if< - !arma::is_arma_type::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "String"; } @@ -87,11 +84,11 @@ inline std::string GetType( template<> inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "Bool"; } @@ -99,9 +96,9 @@ inline std::string GetType( template inline std::string GetType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { return "Vec" + GetType(d); } @@ -109,12 +106,12 @@ inline std::string GetType( template inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { std::string type = ""; - if (std::is_same::value) + if (std::is_same_v) { if (T::is_row) type = "Row"; @@ -123,7 +120,7 @@ inline std::string GetType( else type = "Mat"; } - else if (std::is_same::value) + else if (std::is_same_v) { if (T::is_row) type = "URow"; @@ -139,8 +136,8 @@ inline std::string GetType( template inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { return "MatWithInfo"; } @@ -148,8 +145,8 @@ inline std::string GetType( template inline std::string GetType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { return d.cppType; } @@ -170,7 +167,7 @@ void GetType(util::ParamData& d, void* output) { *((std::string*) output) = - GetType::type>(d); + GetType>(d); } } // namespace r diff --git a/src/mlpack/bindings/R/print_doc.hpp b/src/mlpack/bindings/R/print_doc.hpp index 9acdb03dcf..5dc2ea65a7 100644 --- a/src/mlpack/bindings/R/print_doc.hpp +++ b/src/mlpack/bindings/R/print_doc.hpp @@ -82,7 +82,7 @@ void PrintDoc(util::ParamData& d, } } - oss << " (" << GetRType::type>(d) << ")."; + oss << " (" << GetRType>(d) << ")."; if (out) oss << "}"; diff --git a/src/mlpack/bindings/R/print_input_param.hpp b/src/mlpack/bindings/R/print_input_param.hpp index 4af58ca80c..d56af209c1 100644 --- a/src/mlpack/bindings/R/print_input_param.hpp +++ b/src/mlpack/bindings/R/print_input_param.hpp @@ -29,7 +29,7 @@ void PrintInputParam(util::ParamData& d, void* /* output */) { MLPACK_COUT_STREAM << d.name; - if (std::is_same::value) + if (std::is_same_v) { if (d.name == "verbose") { diff --git a/src/mlpack/bindings/R/print_input_processing.hpp b/src/mlpack/bindings/R/print_input_processing.hpp index 40a073c970..49ce8de9be 100644 --- a/src/mlpack/bindings/R/print_input_processing.hpp +++ b/src/mlpack/bindings/R/print_input_processing.hpp @@ -26,10 +26,10 @@ namespace r { template void PrintInputProcessing( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { if (!d.required) { @@ -72,7 +72,7 @@ void PrintInputProcessing( template void PrintInputProcessing( util::ParamData& d, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { std::string extraTransStr = ""; if (d.cppType == "arma::mat") @@ -135,8 +135,8 @@ void PrintInputProcessing( template void PrintInputProcessing( util::ParamData& d, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { if (!d.required) { @@ -182,8 +182,8 @@ void PrintInputProcessing( template void PrintInputProcessing( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { if (!d.required) { @@ -229,7 +229,7 @@ void PrintInputProcessing(util::ParamData& d, const void* /* input */, void* /* output */) { - PrintInputProcessing::type>(d); + PrintInputProcessing>(d); } } // namespace r diff --git a/src/mlpack/bindings/R/print_output_processing.hpp b/src/mlpack/bindings/R/print_output_processing.hpp index ad06ba31f1..df64d2451d 100644 --- a/src/mlpack/bindings/R/print_output_processing.hpp +++ b/src/mlpack/bindings/R/print_output_processing.hpp @@ -26,10 +26,10 @@ namespace r { template void PrintOutputProcessing( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { /** * This gives us code like: @@ -48,9 +48,9 @@ void PrintOutputProcessing( template void PrintOutputProcessing( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { /** * This gives us code like: @@ -69,8 +69,8 @@ void PrintOutputProcessing( template void PrintOutputProcessing( util::ParamData& d, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { /** * This gives us code like: @@ -89,8 +89,8 @@ void PrintOutputProcessing( template void PrintOutputProcessing( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { /** * This gives us code like: @@ -112,7 +112,7 @@ void PrintOutputProcessing(util::ParamData& d, const void* /*input*/, void* /* output */) { - PrintOutputProcessing::type>(d); + PrintOutputProcessing>(d); } } // namespace r diff --git a/src/mlpack/bindings/R/print_serialize_util.hpp b/src/mlpack/bindings/R/print_serialize_util.hpp index 362adbfe34..4a44781061 100644 --- a/src/mlpack/bindings/R/print_serialize_util.hpp +++ b/src/mlpack/bindings/R/print_serialize_util.hpp @@ -25,8 +25,8 @@ namespace r { template void PrintSerializeUtil( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Do Nothing. } @@ -37,7 +37,7 @@ void PrintSerializeUtil( template void PrintSerializeUtil( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // Do Nothing. } @@ -48,8 +48,8 @@ void PrintSerializeUtil( template void PrintSerializeUtil( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { /** * This gives us code like: @@ -76,7 +76,7 @@ void PrintSerializeUtil(util::ParamData& d, const void* /*input*/, void* /* output */) { - PrintSerializeUtil::type>(d); + PrintSerializeUtil>(d); } } // namespace r diff --git a/src/mlpack/bindings/R/print_type_doc.hpp b/src/mlpack/bindings/R/print_type_doc.hpp index 5f0253578b..9925372eee 100644 --- a/src/mlpack/bindings/R/print_type_doc.hpp +++ b/src/mlpack/bindings/R/print_type_doc.hpp @@ -25,11 +25,11 @@ namespace r { template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a vector. @@ -37,7 +37,7 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix option. @@ -45,7 +45,7 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix tuple option. @@ -53,8 +53,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a model. @@ -62,8 +62,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Print the command-line type of an option into a string. @@ -74,7 +74,7 @@ void PrintTypeDoc(util::ParamData& data, void* output) { *((std::string*) output) = - PrintTypeDoc::type>(data); + PrintTypeDoc>(data); } } // namespace r diff --git a/src/mlpack/bindings/R/print_type_doc_impl.hpp b/src/mlpack/bindings/R/print_type_doc_impl.hpp index bc8ba85f25..a5f837a811 100644 --- a/src/mlpack/bindings/R/print_type_doc_impl.hpp +++ b/src/mlpack/bindings/R/print_type_doc_impl.hpp @@ -24,29 +24,29 @@ namespace r { template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { // A flag type. - if (std::is_same::value) + if (std::is_same_v) { return "A boolean flag option (i.e. `TRUE` or `FALSE`)."; } // An integer. - else if (std::is_same::value) + else if (std::is_same_v) { return "An integer (i.e., `1`)."; } // A floating point value. - else if (std::is_same::value) + else if (std::is_same_v) { return "A floating-point number (i.e., `0.5`)."; } // A string. - else if (std::is_same::value) + else if (std::is_same_v) { return "A character string (i.e., `\"hello\"`)."; } @@ -64,13 +64,13 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same>::value) + if (std::is_same_v>) { return "A vector of integers; i.e., `c(0, 1, 2)`."; } - else if (std::is_same>::value) + else if (std::is_same_v>) { return "A vector of strings; i.e., `c(\"hello\", \"goodbye\")`."; } @@ -86,9 +86,9 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same::value) + if (std::is_same_v) { if (T::is_col || T::is_row) { @@ -102,7 +102,7 @@ std::string PrintTypeDoc( "2-d `matrix`)."; } } - else if (std::is_same::value) + else if (std::is_same_v) { if (T::is_col || T::is_row) { @@ -128,8 +128,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& /* data */, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return "A 2-d array containing `numeric` data. Like the regular 2-d matrices" ", this can be a `matrix`, or a `data.frame`. However, this type can also" @@ -146,8 +146,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& /* data */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "An mlpack model pointer. `` refers to the type of model that " "is being stored, so, e.g., for `cf()`, the type will be `CFModel`. " diff --git a/src/mlpack/bindings/cli/add_to_cli11.hpp b/src/mlpack/bindings/cli/add_to_cli11.hpp index c9b0e87bae..907eb1d3bc 100644 --- a/src/mlpack/bindings/cli/add_to_cli11.hpp +++ b/src/mlpack/bindings/cli/add_to_cli11.hpp @@ -33,15 +33,12 @@ template void AddToCLI11(const std::string& cliName, util::ParamData& param, CLI::App& app, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>::value>::type* = 0) + arma::mat>>>* = 0) { app.add_option_function(cliName.c_str(), [¶m](const std::string& value) @@ -65,15 +62,12 @@ template void AddToCLI11(const std::string& cliName, util::ParamData& param, CLI::App& app, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if< - data::HasSerialize::value>::type* = 0, - const typename std::enable_if>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>::value>::type* = 0) + arma::mat>>>* = 0) { app.add_option_function(cliName.c_str(), [¶m](const std::string& value) @@ -97,13 +91,11 @@ template void AddToCLI11(const std::string& cliName, util::ParamData& param, CLI::App& app, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if< - arma::is_arma_type::value>::type* = 0, - const typename std::enable_if>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>::value>::type* = 0) + arma::mat>>>* = 0) { app.add_option_function(cliName.c_str(), [¶m](const std::string& value) @@ -127,15 +119,12 @@ template void AddToCLI11(const std::string& cliName, util::ParamData& param, CLI::App& app, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>::value>::type* = 0) + arma::mat>>>* = 0) { app.add_option_function(cliName.c_str(), [¶m](const T& value) @@ -157,15 +146,12 @@ template void AddToCLI11(const std::string& cliName, util::ParamData& param, CLI::App& app, - const typename std::enable_if< - std::is_same::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>::value>::type* = 0) + arma::mat>>>* = 0) { app.add_flag_function(cliName.c_str(), [¶m](const T& value) @@ -194,14 +180,14 @@ void AddToCLI11(util::ParamData& param, // Generate the name to be given to CLI11. const std::string mappedName = - MapParameterName::type>(param.name); + MapParameterName>(param.name); std::string cliName = (param.alias != '\0') ? "-" + std::string(1, param.alias) + ",--" + mappedName : "--" + mappedName; // Note that we have to add the option as type equal to the mapped type, not // the true type of the option. - AddToCLI11::type>( + AddToCLI11>( cliName, param, *app); } diff --git a/src/mlpack/bindings/cli/cli_option.hpp b/src/mlpack/bindings/cli/cli_option.hpp index 52c41474ce..af9a83057f 100644 --- a/src/mlpack/bindings/cli/cli_option.hpp +++ b/src/mlpack/bindings/cli/cli_option.hpp @@ -91,21 +91,20 @@ class CLIOption data.cppType = cppName; // Apply default value. - if (std::is_same::type, - typename ParameterType::type>::type>::value) + if (std::is_same_v, + typename ParameterType>::type>) { data.value = defaultValue; } else { - typename ParameterType::type>::type tmp; + typename ParameterType>::type tmp; data.value = std::tuple(defaultValue, tmp); } const std::string tname = data.tname; const std::string cliName = MapParameterName< - typename std::remove_pointer::type>(identifier); + std::remove_pointer_t>(identifier); std::string progOptId = (alias[0] != '\0') ? "-" + std::string(1, alias[0]) + ",--" + cliName : "--" + cliName; diff --git a/src/mlpack/bindings/cli/default_param.hpp b/src/mlpack/bindings/cli/default_param.hpp index f8d97bdc1c..7bdda5972b 100644 --- a/src/mlpack/bindings/cli/default_param.hpp +++ b/src/mlpack/bindings/cli/default_param.hpp @@ -26,13 +26,12 @@ namespace cli { template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>* = 0, + const std::enable_if_t>>* = 0); /** * Return the default value of a vector option. @@ -40,7 +39,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return the default value of a string option. @@ -48,8 +47,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value - >::type* = 0); + const std::enable_if_t>* = 0); /** * Return the default value of a matrix option, a tuple option, a @@ -59,10 +57,10 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value>::type* /* junk */ = 0); + std::is_same_v>>* /* junk */ = 0); /** * Return the default value of a model option (this returns the default @@ -71,8 +69,8 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Return the default value of an option. This is the function that will be @@ -84,7 +82,7 @@ void DefaultParam(util::ParamData& data, void* output) { std::string* outstr = (std::string*) output; - *outstr = DefaultParamImpl::type>(data); + *outstr = DefaultParamImpl>(data); } } // namespace cli diff --git a/src/mlpack/bindings/cli/default_param_impl.hpp b/src/mlpack/bindings/cli/default_param_impl.hpp index 498f950ff8..cdefb16d22 100644 --- a/src/mlpack/bindings/cli/default_param_impl.hpp +++ b/src/mlpack/bindings/cli/default_param_impl.hpp @@ -24,16 +24,15 @@ namespace cli { template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>*, + const std::enable_if_t>>*) { std::ostringstream oss; - if (!std::is_same::value) + if (!std::is_same_v) oss << std::any_cast(data.value); return oss.str(); @@ -45,13 +44,13 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { // Print each element in an array delimited by square brackets. std::ostringstream oss; const T& vector = std::any_cast(data.value); oss << "["; - if (std::is_same>::value) + if (std::is_same_v>) { if (vector.size() > 0) { @@ -89,7 +88,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t>*) { const std::string& s = *std::any_cast(&data.value); return "'" + s + "'"; @@ -101,10 +100,10 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& /* data */, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value>::type* /* junk */) + std::is_same_v>>* /* junk */) { // The filename will always be empty. return "''"; @@ -116,8 +115,8 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& /* data */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "''"; } diff --git a/src/mlpack/bindings/cli/delete_allocated_memory.hpp b/src/mlpack/bindings/cli/delete_allocated_memory.hpp index d6c8c2f814..d73715fa59 100644 --- a/src/mlpack/bindings/cli/delete_allocated_memory.hpp +++ b/src/mlpack/bindings/cli/delete_allocated_memory.hpp @@ -21,8 +21,8 @@ namespace cli { template void DeleteAllocatedMemoryImpl( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Do nothing. } @@ -30,7 +30,7 @@ void DeleteAllocatedMemoryImpl( template void DeleteAllocatedMemoryImpl( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // Do nothing. } @@ -38,8 +38,8 @@ void DeleteAllocatedMemoryImpl( template void DeleteAllocatedMemoryImpl( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Delete the allocated memory (hopefully we actually own it). typedef std::tuple TupleType; @@ -52,7 +52,7 @@ void DeleteAllocatedMemory( const void* /* input */, void* /* output */) { - DeleteAllocatedMemoryImpl::type>(d); + DeleteAllocatedMemoryImpl>(d); } } // namespace cli diff --git a/src/mlpack/bindings/cli/get_allocated_memory.hpp b/src/mlpack/bindings/cli/get_allocated_memory.hpp index 426cf350cb..6cc4d2e94e 100644 --- a/src/mlpack/bindings/cli/get_allocated_memory.hpp +++ b/src/mlpack/bindings/cli/get_allocated_memory.hpp @@ -22,8 +22,8 @@ namespace cli { template void* GetAllocatedMemory( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { return NULL; } @@ -31,7 +31,7 @@ void* GetAllocatedMemory( template void* GetAllocatedMemory( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { return NULL; } @@ -39,8 +39,8 @@ void* GetAllocatedMemory( template void* GetAllocatedMemory( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Here we have a model, which is a tuple, and we need the address of the // memory. @@ -53,8 +53,7 @@ void GetAllocatedMemory(util::ParamData& d, const void* /* input */, void* output) { - *((void**) output) = - GetAllocatedMemory::type>(d); + *((void**) output) = GetAllocatedMemory>(d); } } // namespace cli diff --git a/src/mlpack/bindings/cli/get_param.hpp b/src/mlpack/bindings/cli/get_param.hpp index 528f0f8753..a768a2902a 100644 --- a/src/mlpack/bindings/cli/get_param.hpp +++ b/src/mlpack/bindings/cli/get_param.hpp @@ -28,10 +28,10 @@ namespace cli { template T& GetParam( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { // No mapping is needed, so just cast it directly. return *std::any_cast(&d.value); @@ -45,7 +45,7 @@ T& GetParam( template T& GetParam( util::ParamData& d, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // If the matrix is an input matrix, we have to load the matrix. 'value' // contains the filename. It's possible we could load empty matrices many @@ -80,8 +80,8 @@ T& GetParam( template T& GetParam( util::ParamData& d, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { // If this is an input parameter, we need to load both the matrix and the // dataset info. @@ -110,8 +110,8 @@ T& GetParam( template T*& GetParam( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // If the model is an input model, we have to load it from file. 'value' // contains the filename. @@ -140,7 +140,7 @@ template void GetParam(util::ParamData& d, const void* /* input */, void* output) { // Cast to the correct type. - *((T**) output) = &GetParam::type>(d); + *((T**) output) = &GetParam>(d); } } // namespace cli diff --git a/src/mlpack/bindings/cli/get_printable_param.hpp b/src/mlpack/bindings/cli/get_printable_param.hpp index 2cd2221101..c8c25f3a9f 100644 --- a/src/mlpack/bindings/cli/get_printable_param.hpp +++ b/src/mlpack/bindings/cli/get_printable_param.hpp @@ -27,11 +27,11 @@ namespace cli { template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Print a vector option, with spaces between it. @@ -39,7 +39,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Print a matrix/tuple option (this just prints the filename). @@ -47,9 +47,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value || - std::is_same>::value>::type* = 0); + const std::enable_if_t::value || std::is_same_v>>* = 0); /** * Print a model option (this just prints the filename). @@ -57,8 +56,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Print an option into a std::string. This should print a short, one-line @@ -71,7 +70,7 @@ void GetPrintableParam(util::ParamData& data, void* output) { *((std::string*) output) = - GetPrintableParam::type>(data); + GetPrintableParam>(data); } } // namespace cli diff --git a/src/mlpack/bindings/cli/get_printable_param_impl.hpp b/src/mlpack/bindings/cli/get_printable_param_impl.hpp index 6e7ae18c42..3bbd8989fc 100644 --- a/src/mlpack/bindings/cli/get_printable_param_impl.hpp +++ b/src/mlpack/bindings/cli/get_printable_param_impl.hpp @@ -23,11 +23,11 @@ namespace cli { template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { std::ostringstream oss; oss << std::any_cast(data.value); @@ -38,8 +38,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* - /* junk */) + const std::enable_if_t::value>* /* junk */) { const T& t = std::any_cast(data.value); @@ -53,7 +52,7 @@ std::string GetPrintableParam( template std::string GetMatrixSize( T& matrix, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { std::ostringstream oss; oss << matrix.n_rows << "x" << matrix.n_cols << " matrix"; @@ -64,8 +63,8 @@ std::string GetMatrixSize( template std::string GetMatrixSize( T& matrixAndInfo, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { return GetMatrixSize(std::get<1>(matrixAndInfo)); } @@ -74,9 +73,8 @@ std::string GetMatrixSize( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value || - std::is_same>::value>::type* /* junk */) + const std::enable_if_t::value || std::is_same_v>>* /* junk */) { // Extract the string from the tuple that's being held. typedef std::tuple::type> TupleType; @@ -103,8 +101,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { // Extract the string from the tuple that's being held. typedef std::tuple::type> TupleType; diff --git a/src/mlpack/bindings/cli/get_printable_param_name.hpp b/src/mlpack/bindings/cli/get_printable_param_name.hpp index b875d2f72d..f5619ca377 100644 --- a/src/mlpack/bindings/cli/get_printable_param_name.hpp +++ b/src/mlpack/bindings/cli/get_printable_param_name.hpp @@ -26,10 +26,10 @@ namespace cli { template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Get the parameter name for a matrix type (where the user has to pass the file @@ -38,7 +38,7 @@ std::string GetPrintableParamName( template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Get the parameter name for a serializable model type (where the user has to @@ -47,8 +47,8 @@ std::string GetPrintableParamName( template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Get the parameter name for a mapped matrix type (where the user has to pass @@ -57,8 +57,8 @@ std::string GetPrintableParamName( template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Get the parameter's name as seen by the user. @@ -70,7 +70,7 @@ void GetPrintableParamName( void* output) { *((std::string*) output) = - GetPrintableParamName::type>(d); + GetPrintableParamName>(d); } } // namespace cli diff --git a/src/mlpack/bindings/cli/get_printable_param_name_impl.hpp b/src/mlpack/bindings/cli/get_printable_param_name_impl.hpp index 7c355c3dbc..3d21f56b2a 100644 --- a/src/mlpack/bindings/cli/get_printable_param_name_impl.hpp +++ b/src/mlpack/bindings/cli/get_printable_param_name_impl.hpp @@ -26,10 +26,10 @@ namespace cli { template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "--" + data.name; } @@ -41,7 +41,7 @@ std::string GetPrintableParamName( template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { return "--" + data.name + "_file"; } @@ -53,8 +53,8 @@ std::string GetPrintableParamName( template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "--" + data.name + "_file"; } @@ -66,8 +66,8 @@ std::string GetPrintableParamName( template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return "--" + data.name + "_file"; } diff --git a/src/mlpack/bindings/cli/get_printable_param_value.hpp b/src/mlpack/bindings/cli/get_printable_param_value.hpp index 621640b3c1..f7be9a7b7b 100644 --- a/src/mlpack/bindings/cli/get_printable_param_value.hpp +++ b/src/mlpack/bindings/cli/get_printable_param_value.hpp @@ -27,10 +27,10 @@ template std::string GetPrintableParamValue( util::ParamData& data, const std::string& value, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Get the parameter name for a matrix type (where the user has to pass the file @@ -40,7 +40,7 @@ template std::string GetPrintableParamValue( util::ParamData& data, const std::string& value, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Get the parameter name for a serializable model type (where the user has to @@ -50,8 +50,8 @@ template std::string GetPrintableParamValue( util::ParamData& data, const std::string& value, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Get the parameter name for a mapped matrix type (where the user has to pass @@ -61,8 +61,8 @@ template std::string GetPrintableParamValue( util::ParamData& data, const std::string& value, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Get the parameter's name as seen by the user. @@ -74,7 +74,7 @@ void GetPrintableParamValue( void* output) { *((std::string*) output) = - GetPrintableParamValue::type>(d, + GetPrintableParamValue>(d, *((std::string*) input)); } diff --git a/src/mlpack/bindings/cli/get_printable_param_value_impl.hpp b/src/mlpack/bindings/cli/get_printable_param_value_impl.hpp index 3bb42b01b1..96785cc5d8 100644 --- a/src/mlpack/bindings/cli/get_printable_param_value_impl.hpp +++ b/src/mlpack/bindings/cli/get_printable_param_value_impl.hpp @@ -28,10 +28,10 @@ template std::string GetPrintableParamValue( util::ParamData& /* data */, const std::string& input, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return input; } @@ -44,7 +44,7 @@ template std::string GetPrintableParamValue( util::ParamData& /* data */, const std::string& input, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { return input + ".csv"; } @@ -57,8 +57,8 @@ template std::string GetPrintableParamValue( util::ParamData& /* data */, const std::string& input, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return input + ".bin"; } @@ -71,8 +71,8 @@ template std::string GetPrintableParamValue( util::ParamData& /* data */, const std::string& input, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return input + ".arff"; } diff --git a/src/mlpack/bindings/cli/get_printable_type.hpp b/src/mlpack/bindings/cli/get_printable_type.hpp index 07fd10609a..1e6e127d2a 100644 --- a/src/mlpack/bindings/cli/get_printable_type.hpp +++ b/src/mlpack/bindings/cli/get_printable_type.hpp @@ -23,11 +23,11 @@ namespace cli { template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a vector. @@ -35,7 +35,7 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix option. @@ -43,7 +43,7 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix tuple option. @@ -51,8 +51,8 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a model. @@ -60,8 +60,8 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Print the command-line type of an option into a string. @@ -71,8 +71,7 @@ void GetPrintableType(util::ParamData& data, const void* /* input */, void* output) { - *((std::string*) output) = - GetPrintableType::type>(data); + *((std::string*) output) = GetPrintableType>(data); } } // namespace cli diff --git a/src/mlpack/bindings/cli/get_printable_type_impl.hpp b/src/mlpack/bindings/cli/get_printable_type_impl.hpp index 14a259b8b6..d3dbbf5050 100644 --- a/src/mlpack/bindings/cli/get_printable_type_impl.hpp +++ b/src/mlpack/bindings/cli/get_printable_type_impl.hpp @@ -25,19 +25,19 @@ namespace cli { template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { - if (std::is_same::value) + if (std::is_same_v) return "flag"; - else if (std::is_same::value) + else if (std::is_same_v) return "int"; - else if (std::is_same::value) + else if (std::is_same_v) return "double"; - else if (std::is_same::value) + else if (std::is_same_v) return "string"; else throw std::invalid_argument("unknown parameter type" + data.cppType); @@ -49,11 +49,11 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same>::value) + if (std::is_same_v>) return "int vector"; - else if (std::is_same>::value) + else if (std::is_same_v>) return "string vector"; else throw std::invalid_argument("unknown vector type " + data.cppType); @@ -65,19 +65,19 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same::value) + if (std::is_same_v) return "2-d matrix file"; - else if (std::is_same>::value) + else if (std::is_same_v>) return "2-d index matrix file"; - else if (std::is_same::value) + else if (std::is_same_v) return "1-d matrix file"; - else if (std::is_same>::value) + else if (std::is_same_v>) return "1-d index matrix file"; - else if (std::is_same::value) + else if (std::is_same_v) return "1-d matrix file"; - else if (std::is_same>::value) + else if (std::is_same_v>) return "1-d index matrix file"; else throw std::invalid_argument("unknown Armadillo type" + data.cppType); @@ -89,8 +89,8 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& /* data */, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return "2-d categorical matrix file"; } @@ -101,8 +101,8 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return data.cppType + " file"; } diff --git a/src/mlpack/bindings/cli/get_raw_param.hpp b/src/mlpack/bindings/cli/get_raw_param.hpp index 0724a542f3..5464b01d72 100644 --- a/src/mlpack/bindings/cli/get_raw_param.hpp +++ b/src/mlpack/bindings/cli/get_raw_param.hpp @@ -27,10 +27,10 @@ namespace cli { template T& GetRawParam( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { // No mapping is needed, so just cast it directly. return *std::any_cast(&d.value); @@ -42,10 +42,10 @@ T& GetRawParam( template T& GetRawParam( util::ParamData& d, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value>::type* = 0) + std::is_same_v>>* = 0) { // Don't load the matrix. typedef std::tuple> TupleType; @@ -59,8 +59,8 @@ T& GetRawParam( template T*& GetRawParam( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Don't load the model. typedef std::tuple TupleType; @@ -82,7 +82,7 @@ void GetRawParam(util::ParamData& d, void* output) { // Cast to the correct type. - *((T**) output) = &GetRawParam::type>( + *((T**) output) = &GetRawParam>( const_cast(d)); } diff --git a/src/mlpack/bindings/cli/in_place_copy.hpp b/src/mlpack/bindings/cli/in_place_copy.hpp index 4ffbb0e03d..2e8b2a5efc 100644 --- a/src/mlpack/bindings/cli/in_place_copy.hpp +++ b/src/mlpack/bindings/cli/in_place_copy.hpp @@ -31,10 +31,10 @@ template void InPlaceCopyInternal( util::ParamData& /* d */, util::ParamData& /* input */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { // Nothing to do. } @@ -50,11 +50,10 @@ template void InPlaceCopyInternal( util::ParamData& d, util::ParamData& input, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value - >::type* = 0) + std::is_same_v>>* + = 0) { // Make the output filename the same as the input filename. typedef std::tuple::type> TupleType; @@ -76,8 +75,7 @@ template void InPlaceCopyInternal( util::ParamData& d, util::ParamData& input, - const typename std::enable_if< - data::HasSerialize::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // Make the output filename the same as the input filename. typedef std::tuple::type> TupleType; @@ -102,7 +100,7 @@ void InPlaceCopy(util::ParamData& d, void* /* output */) { // Cast to the correct type. - InPlaceCopyInternal::type>( + InPlaceCopyInternal>( const_cast(d), *((util::ParamData*) input)); } diff --git a/src/mlpack/bindings/cli/map_parameter_name.hpp b/src/mlpack/bindings/cli/map_parameter_name.hpp index 74f20a6431..17235ed3a1 100644 --- a/src/mlpack/bindings/cli/map_parameter_name.hpp +++ b/src/mlpack/bindings/cli/map_parameter_name.hpp @@ -27,10 +27,10 @@ namespace cli { template std::string MapParameterName( const std::string& identifier, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { return identifier; } @@ -43,11 +43,10 @@ std::string MapParameterName( template std::string MapParameterName( const std::string& identifier, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value || - data::HasSerialize::value>::type* /* junk */ = 0) + std::is_same_v> || + data::HasSerialize::value>* /* junk */ = 0) { return identifier + "_file"; } @@ -67,7 +66,7 @@ void MapParameterName(util::ParamData& d, // Store the mapped name in the output pointer, which is actually a string // pointer. *((std::string*) output) = - MapParameterName::type>(d.name); + MapParameterName>(d.name); } } // namespace cli diff --git a/src/mlpack/bindings/cli/output_param.hpp b/src/mlpack/bindings/cli/output_param.hpp index bef23ed43e..9fd335caab 100644 --- a/src/mlpack/bindings/cli/output_param.hpp +++ b/src/mlpack/bindings/cli/output_param.hpp @@ -26,11 +26,11 @@ namespace cli { template void OutputParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Output a vector option (print to stdout). @@ -38,7 +38,7 @@ void OutputParamImpl( template void OutputParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Output a matrix option (this saves it to the given file). @@ -46,7 +46,7 @@ void OutputParamImpl( template void OutputParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Output a serializable class option (this saves it to the given file). @@ -54,8 +54,8 @@ void OutputParamImpl( template void OutputParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Output a mapped dataset. @@ -63,8 +63,8 @@ void OutputParamImpl( template void OutputParamImpl( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Output an option. This is the function that will be called by the IO @@ -75,7 +75,7 @@ void OutputParam(util::ParamData& data, const void* /* input */, void* /* output */) { - OutputParamImpl::type>(data); + OutputParamImpl>(data); } } // namespace cli diff --git a/src/mlpack/bindings/cli/output_param_impl.hpp b/src/mlpack/bindings/cli/output_param_impl.hpp index 1725a2e890..0addc718b8 100644 --- a/src/mlpack/bindings/cli/output_param_impl.hpp +++ b/src/mlpack/bindings/cli/output_param_impl.hpp @@ -24,11 +24,11 @@ namespace cli { template void OutputParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { std::cout << data.name << ": " << *std::any_cast(&data.value) << std::endl; @@ -38,7 +38,7 @@ void OutputParamImpl( template void OutputParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { std::cout << data.name << ": "; const T& t = *std::any_cast(&data.value); @@ -51,7 +51,7 @@ void OutputParamImpl( template void OutputParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { typedef std::tuple> TupleType; const T& output = std::get<0>(*std::any_cast(&data.value)); @@ -71,8 +71,8 @@ void OutputParamImpl( template void OutputParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { // The const cast is necessary here because Serialize() can't ever be marked // const. In this case we can assume it though, since we will be saving and @@ -91,8 +91,8 @@ void OutputParamImpl( template void OutputParamImpl( util::ParamData& data, - const typename std::enable_if>::value>::type* /* junk */) + const std::enable_if_t>>* /* junk */) { // Output the matrix with the mappings. typedef std::tuple> TupleType; diff --git a/src/mlpack/bindings/cli/print_type_doc.hpp b/src/mlpack/bindings/cli/print_type_doc.hpp index 10acab4f5b..630ebf7f9b 100644 --- a/src/mlpack/bindings/cli/print_type_doc.hpp +++ b/src/mlpack/bindings/cli/print_type_doc.hpp @@ -25,11 +25,11 @@ namespace cli { template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a vector. @@ -37,7 +37,7 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix option. @@ -45,7 +45,7 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix tuple option. @@ -53,8 +53,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a model. @@ -62,8 +62,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Print the command-line type of an option into a string. @@ -73,8 +73,7 @@ void PrintTypeDoc(util::ParamData& data, const void* /* input */, void* output) { - *((std::string*) output) = - PrintTypeDoc::type>(data); + *((std::string*) output) = PrintTypeDoc>(data); } } // namespace cli diff --git a/src/mlpack/bindings/cli/print_type_doc_impl.hpp b/src/mlpack/bindings/cli/print_type_doc_impl.hpp index 1836732bf8..8a95d8666f 100644 --- a/src/mlpack/bindings/cli/print_type_doc_impl.hpp +++ b/src/mlpack/bindings/cli/print_type_doc_impl.hpp @@ -24,30 +24,30 @@ namespace cli { template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { // A flag type. - if (std::is_same::value) + if (std::is_same_v) { return "A boolean flag option. If not specified, it is false; if " "specified, it is true."; } // An integer. - else if (std::is_same::value) + else if (std::is_same_v) { return "An integer (i.e., \"1\")."; } // A floating point value. - else if (std::is_same::value) + else if (std::is_same_v) { return "A floating-point number (i.e., \"0.5\")."; } // A string. - else if (std::is_same::value) + else if (std::is_same_v) { return "A character string (i.e., \"hello\")."; } @@ -64,13 +64,13 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same>::value) + if (std::is_same_v>) { return "A vector of integers, separated by commas (i.e., \"1,2,3\")."; } - else if (std::is_same>::value) + else if (std::is_same_v>) { return "A vector of strings, separated by commas (i.e., " "\"hello\",\"goodbye\")."; @@ -87,9 +87,9 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same::value) + if (std::is_same_v) { return "A data matrix filename. The file can be CSV (.csv), TSV (.csv), " "ASCII (space-separated values, .txt), Armadillo ASCII (.txt), PGM " @@ -102,7 +102,7 @@ std::string PrintTypeDoc( "is found, the first row will be loaded as a data point. All values of" " the matrix will be loaded as double-precision floating point data."; } - else if (std::is_same>::value) + else if (std::is_same_v>) { return "A data matrix filename, where the matrix holds only non-negative " "integer values. This type is often used for labels or indices. The " @@ -117,15 +117,15 @@ std::string PrintTypeDoc( " loaded as a data point. All values of the matrix will be loaded as " "unsigned integers."; } - else if (std::is_same::value || - std::is_same::value) + else if (std::is_same_v || + std::is_same_v) { return "A one-dimensional vector filename. This file can take the same " "formats as the data matrix filenames; however, it must either contain " "one row and many columns, or one column and many rows."; } - else if (std::is_same>::value || - std::is_same>::value) + else if (std::is_same_v> || + std::is_same_v>) { return "A one-dimensional vector filename, where the matrix holds only non-" "negative integer values. This type is typically used for labels or " @@ -145,8 +145,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& /* data */, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return "A filename for a data matrix that can contain categorical " "(non-numeric) data. If the file contains only numeric data, then the " @@ -165,8 +165,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& /* data */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "A filename containing an mlpack model. These can have one of three " "formats: binary (.bin), text (.txt), and XML (.xml). The XML format " diff --git a/src/mlpack/bindings/cli/set_param.hpp b/src/mlpack/bindings/cli/set_param.hpp index df2fb85bcd..73f493c660 100644 --- a/src/mlpack/bindings/cli/set_param.hpp +++ b/src/mlpack/bindings/cli/set_param.hpp @@ -27,11 +27,11 @@ template void SetParam( util::ParamData& d, const std::any& value, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0, + const std::enable_if_t>* = 0) { // No mapping is needed. d.value = *std::any_cast(&value); @@ -44,7 +44,7 @@ template void SetParam( util::ParamData& d, const std::any& /* value */, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t>* = 0) { // Force set to the value of whether or not this was passed. d.value = d.wasPassed; @@ -58,9 +58,8 @@ template void SetParam( util::ParamData& d, const std::any& value, - const typename std::enable_if::value || - std::is_same>::value>::type* = 0) + const std::enable_if_t::value || std::is_same_v>>* = 0) { // We're setting the string filename. typedef std::tuple::type> TupleType; @@ -76,8 +75,8 @@ template void SetParam( util::ParamData& d, const std::any& value, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // We're setting the string filename. typedef std::tuple::type> TupleType; @@ -96,7 +95,7 @@ void SetParam( template void SetParam(util::ParamData& d, const void* input, void* /* output */) { - SetParam::type>( + SetParam>( const_cast(d), *((std::any*) input)); } diff --git a/src/mlpack/bindings/cli/string_type_param.hpp b/src/mlpack/bindings/cli/string_type_param.hpp index decf9e794d..bd9e2c81ef 100644 --- a/src/mlpack/bindings/cli/string_type_param.hpp +++ b/src/mlpack/bindings/cli/string_type_param.hpp @@ -26,22 +26,22 @@ namespace cli { */ template std::string StringTypeParamImpl( - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Return a string containing the type of the parameter, for vector options. */ template std::string StringTypeParamImpl( - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string containing the type of the parameter, */ template std::string StringTypeParamImpl( - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string containing the type of a parameter. This overload is used if diff --git a/src/mlpack/bindings/cli/string_type_param_impl.hpp b/src/mlpack/bindings/cli/string_type_param_impl.hpp index f0fc89a34c..5bc52703cb 100644 --- a/src/mlpack/bindings/cli/string_type_param_impl.hpp +++ b/src/mlpack/bindings/cli/string_type_param_impl.hpp @@ -23,8 +23,8 @@ namespace cli { */ template std::string StringTypeParamImpl( - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { // Don't know what type this is. return "unknown"; @@ -35,7 +35,7 @@ std::string StringTypeParamImpl( */ template std::string StringTypeParamImpl( - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { return "vector"; } @@ -45,7 +45,7 @@ std::string StringTypeParamImpl( */ template std::string StringTypeParamImpl( - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { return "string"; } diff --git a/src/mlpack/bindings/go/default_param.hpp b/src/mlpack/bindings/go/default_param.hpp index 38c7272a00..e67185d619 100644 --- a/src/mlpack/bindings/go/default_param.hpp +++ b/src/mlpack/bindings/go/default_param.hpp @@ -26,13 +26,12 @@ namespace go { template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>* = 0, + const std::enable_if_t>>* = 0); /** * Return the default value of a vector option. @@ -40,7 +39,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return the default value of a string option. @@ -48,8 +47,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value - >::type* = 0); + const std::enable_if_t>* = 0); /** * Return the default value of a matrix option, a tuple option, a @@ -59,10 +57,10 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value>::type* = 0); + std::is_same_v>>* = 0); /** * Return the default value of a model option (this returns the default @@ -71,8 +69,8 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Return the default value of an option. This is the function that will be @@ -84,7 +82,7 @@ void DefaultParam(util::ParamData& data, void* output) { std::string* outstr = (std::string*) output; - *outstr = DefaultParamImpl::type>(data); + *outstr = DefaultParamImpl>(data); } } // namespace go diff --git a/src/mlpack/bindings/go/default_param_impl.hpp b/src/mlpack/bindings/go/default_param_impl.hpp index 12a80f1f2b..6d78a5ef1c 100644 --- a/src/mlpack/bindings/go/default_param_impl.hpp +++ b/src/mlpack/bindings/go/default_param_impl.hpp @@ -24,16 +24,15 @@ namespace go { template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>*, + const std::enable_if_t>>*) { std::ostringstream oss; - if (std::is_same::value) + if (std::is_same_v) oss << "false"; else oss << std::any_cast(data.value); @@ -47,12 +46,12 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { // Print each element in an array delimited by square brackets. std::ostringstream oss; const T& vector = std::any_cast(data.value); - if (std::is_same>::value) + if (std::is_same_v>) { oss << "[]string{"; if (vector.size() > 0) @@ -67,7 +66,7 @@ std::string DefaultParamImpl( oss << "}"; } - else if (std::is_same>::value) + else if (std::is_same_v>) { oss << "[]int{"; if (vector.size() > 0) @@ -91,7 +90,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t>*) { const std::string& s = *std::any_cast(&data.value); return "\"" + s + "\""; @@ -103,23 +102,22 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& /* data */, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value>::type* /* junk */) + std::is_same_v>>* /* junk */) { // Get the filename and return it, or return an empty string. - if (std::is_same::value || - std::is_same::value) + if (std::is_same_v || std::is_same_v) { return "mat.NewDense(1, 1, nil)"; } - else if (std::is_same>::value || - std::is_same>::value) + else if (std::is_same_v> || + std::is_same_v>) { return "mat.NewDense(1, 1, nil)"; } - else if (std::is_same>::value) + else if (std::is_same_v>) { return "mat.NewDense(1, 1, nil)"; } @@ -135,8 +133,8 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& /* data */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "nil"; } diff --git a/src/mlpack/bindings/go/get_go_type.hpp b/src/mlpack/bindings/go/get_go_type.hpp index 4fc800ecbf..3790a0e0e2 100644 --- a/src/mlpack/bindings/go/get_go_type.hpp +++ b/src/mlpack/bindings/go/get_go_type.hpp @@ -25,11 +25,11 @@ namespace go { template inline std::string GetGoType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { return "unknown"; } @@ -37,11 +37,11 @@ inline std::string GetGoType( template<> inline std::string GetGoType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "int"; } @@ -49,11 +49,11 @@ inline std::string GetGoType( template<> inline std::string GetGoType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "float32"; } @@ -61,11 +61,11 @@ inline std::string GetGoType( template<> inline std::string GetGoType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "float64"; } @@ -73,14 +73,11 @@ inline std::string GetGoType( template<> inline std::string GetGoType( util::ParamData& /* d */, - const typename std::enable_if< - !util::IsStdVector::value>::type*, - const typename std::enable_if< - !data::HasSerialize::value>::type*, - const typename std::enable_if< - !arma::is_arma_type::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "string"; } @@ -88,11 +85,11 @@ inline std::string GetGoType( template<> inline std::string GetGoType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "bool"; } @@ -100,7 +97,7 @@ inline std::string GetGoType( template inline std::string GetGoType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { return "[]" + GetGoType(d); } @@ -108,9 +105,9 @@ inline std::string GetGoType( template inline std::string GetGoType( util::ParamData& /* d */, - const typename std::enable_if>::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t>>* = 0, + const std::enable_if_t::value>* = 0) { return "mat.Dense"; } @@ -118,8 +115,8 @@ inline std::string GetGoType( template inline std::string GetGoType( util::ParamData& /* d */, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { return "matrixWithInfo"; } @@ -127,8 +124,8 @@ inline std::string GetGoType( template inline std::string GetGoType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { std::string goStrippedType, strippedType, printedType, defaultsType; StripType(d.cppType, goStrippedType, strippedType, printedType, defaultsType); diff --git a/src/mlpack/bindings/go/get_printable_param.hpp b/src/mlpack/bindings/go/get_printable_param.hpp index 107e7203c3..2c89eb7fb7 100644 --- a/src/mlpack/bindings/go/get_printable_param.hpp +++ b/src/mlpack/bindings/go/get_printable_param.hpp @@ -25,11 +25,11 @@ namespace go { template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { std::ostringstream oss; oss << std::any_cast(data.value); @@ -42,7 +42,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { const T& t = std::any_cast(data.value); @@ -58,7 +58,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // Get the matrix. const T& matrix = std::any_cast(data.value); @@ -74,8 +74,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { std::ostringstream oss; oss << data.cppType << " model at " << std::any_cast(data.value); @@ -88,16 +88,16 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { // Get the matrix. const T& tuple = std::any_cast(data.value); const arma::mat& matrix = std::get<1>(tuple); std::ostringstream oss; - oss << matrix.n_rows << "x" << matrix.n_cols << " matrix with dimension type " - << "information"; + oss << matrix.n_rows << "x" << matrix.n_cols + << " matrix with dimension type information"; return oss.str(); } @@ -115,8 +115,7 @@ void GetPrintableParam(util::ParamData& data, const void* /* input */, void* output) { - *((std::string*) output) = - GetPrintableParam::type>(data); + *((std::string*) output) = GetPrintableParam>(data); } } // namespace go diff --git a/src/mlpack/bindings/go/get_printable_type.hpp b/src/mlpack/bindings/go/get_printable_type.hpp index 5b2cadece3..e5db191fae 100644 --- a/src/mlpack/bindings/go/get_printable_type.hpp +++ b/src/mlpack/bindings/go/get_printable_type.hpp @@ -23,86 +23,82 @@ namespace go { template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if< - !util::IsStdVector::value>::type*, - const typename std::enable_if< - !data::HasSerialize::value>::type*, - const typename std::enable_if< - !arma::is_arma_type::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template inline std::string GetPrintableType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); template inline std::string GetPrintableType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); template void GetPrintableType(util::ParamData& d, const void* /* input */, void* output) { - *((std::string*) output) = - GetPrintableType::type>(d); + *((std::string*) output) = GetPrintableType>(d); } } // namespace go diff --git a/src/mlpack/bindings/go/get_printable_type_impl.hpp b/src/mlpack/bindings/go/get_printable_type_impl.hpp index cdbfe9feb5..1bde9d0a7a 100644 --- a/src/mlpack/bindings/go/get_printable_type_impl.hpp +++ b/src/mlpack/bindings/go/get_printable_type_impl.hpp @@ -23,11 +23,11 @@ namespace go { template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "unknown"; } @@ -35,11 +35,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "int"; } @@ -47,11 +47,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "float64"; } @@ -59,14 +59,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if< - !util::IsStdVector::value>::type*, - const typename std::enable_if< - !data::HasSerialize::value>::type*, - const typename std::enable_if< - !arma::is_arma_type::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "string"; } @@ -74,11 +71,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "bool"; } @@ -86,9 +83,9 @@ inline std::string GetPrintableType( template inline std::string GetPrintableType( util::ParamData& d, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "array of " + GetPrintableType(d) + "s"; } @@ -96,9 +93,9 @@ inline std::string GetPrintableType( template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { std::string type = "*mat.Dense"; if (T::is_row || T::is_col) @@ -110,8 +107,8 @@ inline std::string GetPrintableType( template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return "matrixWithInfo"; } @@ -119,10 +116,10 @@ inline std::string GetPrintableType( template inline std::string GetPrintableType( util::ParamData& d, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { std::string goStrippedType, strippedType, printedType, defaultsType; StripType(d.cppType, goStrippedType, strippedType, printedType, defaultsType); diff --git a/src/mlpack/bindings/go/get_type.hpp b/src/mlpack/bindings/go/get_type.hpp index 828085d375..1134ee6148 100644 --- a/src/mlpack/bindings/go/get_type.hpp +++ b/src/mlpack/bindings/go/get_type.hpp @@ -24,9 +24,9 @@ namespace go { template inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { return "unknown"; } @@ -34,9 +34,9 @@ inline std::string GetType( template<> inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "Int"; } @@ -44,9 +44,9 @@ inline std::string GetType( template<> inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "Float"; } @@ -54,9 +54,9 @@ inline std::string GetType( template<> inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "Double"; } @@ -64,12 +64,9 @@ inline std::string GetType( template<> inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if< - !util::IsStdVector::value>::type*, - const typename std::enable_if< - !data::HasSerialize::value>::type*, - const typename std::enable_if< - !arma::is_arma_type::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "String"; } @@ -77,9 +74,9 @@ inline std::string GetType( template<> inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "Bool"; } @@ -87,7 +84,7 @@ inline std::string GetType( template inline std::string GetType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { return "Vec" + GetType(d); } @@ -95,10 +92,10 @@ inline std::string GetType( template inline std::string GetType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { std::string type = ""; - if (std::is_same::value) + if (std::is_same_v) { if (T::is_row) type = "Row"; @@ -107,7 +104,7 @@ inline std::string GetType( else type = "Mat"; } - else if (std::is_same::value) + else if (std::is_same_v) { if (T::is_row) type = "Urow"; @@ -123,8 +120,8 @@ inline std::string GetType( template inline std::string GetType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { return d.cppType + "*"; } @@ -144,8 +141,7 @@ void GetType(util::ParamData& d, const void* /* input */, void* output) { - *((std::string*) output) = - GetType::type>(d); + *((std::string*) output) = GetType>(d); } } // namespace go diff --git a/src/mlpack/bindings/go/print_defn_input.hpp b/src/mlpack/bindings/go/print_defn_input.hpp index c51dfa110b..e021b1ec19 100644 --- a/src/mlpack/bindings/go/print_defn_input.hpp +++ b/src/mlpack/bindings/go/print_defn_input.hpp @@ -28,10 +28,10 @@ namespace go { template void PrintDefnInput( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { if (d.required) { @@ -46,7 +46,7 @@ void PrintDefnInput( template void PrintDefnInput( util::ParamData& d, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // param_name *mat.Dense if (d.required) @@ -62,8 +62,8 @@ void PrintDefnInput( template void PrintDefnInput( util::ParamData& d, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { // param_name *DataWithInfo if (d.required) @@ -79,8 +79,8 @@ void PrintDefnInput( template void PrintDefnInput( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Get the type names we need to use. std::string goStrippedType, strippedType, printedType, defaultsType; @@ -113,7 +113,7 @@ void PrintDefnInput(util::ParamData& d, const void* /* input */, void* /* output */) { - PrintDefnInput::type>(d); + PrintDefnInput>(d); } } // namespace go diff --git a/src/mlpack/bindings/go/print_defn_output.hpp b/src/mlpack/bindings/go/print_defn_output.hpp index b18233d1d0..0207c4ea88 100644 --- a/src/mlpack/bindings/go/print_defn_output.hpp +++ b/src/mlpack/bindings/go/print_defn_output.hpp @@ -27,10 +27,10 @@ namespace go { template void PrintDefnOutput( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { std::cout << GetGoType(d); } @@ -41,7 +41,7 @@ void PrintDefnOutput( template void PrintDefnOutput( util::ParamData& d, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // *mat.Dense std::cout << "*" << GetGoType(d); @@ -53,8 +53,8 @@ void PrintDefnOutput( template void PrintDefnOutput( util::ParamData& d, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { // *mat.Dense std::cout << "*" << GetGoType(d); @@ -66,8 +66,8 @@ void PrintDefnOutput( template void PrintDefnOutput( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Get the type names we need to use. std::string goStrippedType, strippedType, printedType, defaultsType; @@ -94,7 +94,7 @@ void PrintDefnOutput(util::ParamData& d, const void* /* input */, void* /* output */) { - PrintDefnOutput::type>(d); + PrintDefnOutput>(d); } } // namespace go diff --git a/src/mlpack/bindings/go/print_doc.hpp b/src/mlpack/bindings/go/print_doc.hpp index 86f3bbe813..05f59cea0b 100644 --- a/src/mlpack/bindings/go/print_doc.hpp +++ b/src/mlpack/bindings/go/print_doc.hpp @@ -45,8 +45,7 @@ void PrintDoc(util::ParamData& d, std::ostringstream oss; oss << " - "; oss << util::CamelCase(d.name, Lower) << " ("; - oss << GetGoType::type>(d) << "): " - << d.desc; + oss << GetGoType>(d) << "): " << d.desc; // Print a default, if possible. if (!d.required) diff --git a/src/mlpack/bindings/go/print_input_processing.hpp b/src/mlpack/bindings/go/print_input_processing.hpp index f46936ea3e..8bd00d1b18 100644 --- a/src/mlpack/bindings/go/print_input_processing.hpp +++ b/src/mlpack/bindings/go/print_input_processing.hpp @@ -29,15 +29,15 @@ template void PrintInputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { const std::string prefix(indent, ' '); std::string def = "nil"; - if (std::is_same::value) + if (std::is_same_v) def = "false"; // Capitalize the first letter of parameter name so it is @@ -131,7 +131,7 @@ template void PrintInputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { const std::string prefix(indent, ' '); @@ -206,8 +206,8 @@ template void PrintInputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { const std::string prefix(indent, ' '); @@ -268,8 +268,8 @@ template void PrintInputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // First, get the correct classparamName if needed. std::string goStrippedType, strippedType, printedType, defaultsType; @@ -340,8 +340,7 @@ void PrintInputProcessing(util::ParamData& d, const void* input, void* /* output */) { - PrintInputProcessing::type>(d, - *((size_t*) input)); + PrintInputProcessing>(d, *((size_t*) input)); } } // namespace go diff --git a/src/mlpack/bindings/go/print_method_config.hpp b/src/mlpack/bindings/go/print_method_config.hpp index 6a51d7205d..2895101377 100644 --- a/src/mlpack/bindings/go/print_method_config.hpp +++ b/src/mlpack/bindings/go/print_method_config.hpp @@ -29,15 +29,15 @@ template void PrintMethodConfig( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { const std::string prefix(indent, ' '); std::string def = "nil"; - if (std::is_same::value) + if (std::is_same_v) def = "false"; // Capitalize the first letter of parameter name so it is @@ -64,12 +64,12 @@ template void PrintMethodConfig( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { const std::string prefix(indent, ' '); std::string def = "nil"; - if (std::is_same::value) + if (std::is_same_v) def = "false"; // Capitalize the first letter of parameter name so it is @@ -96,13 +96,13 @@ template void PrintMethodConfig( util::ParamData& d, const size_t indent, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { const std::string prefix(indent, ' '); std::string def = "nil"; - if (std::is_same::value) + if (std::is_same_v) def = "false"; // Capitalize the first letter of parameter name so it is @@ -129,13 +129,13 @@ template void PrintMethodConfig( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { const std::string prefix(indent, ' '); std::string def = "nil"; - if (std::is_same::value) + if (std::is_same_v) def = "false"; // Capitalize the first letter of parameter name so it is @@ -171,8 +171,7 @@ void PrintMethodConfig(util::ParamData& d, const void* input, void* /* output */) { - PrintMethodConfig::type>(d, - *((size_t*) input)); + PrintMethodConfig>(d, *((size_t*) input)); } } // namespace go diff --git a/src/mlpack/bindings/go/print_method_init.hpp b/src/mlpack/bindings/go/print_method_init.hpp index ef766f2536..e2fab09052 100644 --- a/src/mlpack/bindings/go/print_method_init.hpp +++ b/src/mlpack/bindings/go/print_method_init.hpp @@ -29,15 +29,15 @@ template void PrintMethodInit( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { const std::string prefix(indent, ' '); std::string def = "nil"; - if (std::is_same::value) + if (std::is_same_v) def = "false"; // Capitalize the first letter of parameter name so it is @@ -86,12 +86,12 @@ template void PrintMethodInit( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { const std::string prefix(indent, ' '); std::string def = "nil"; - if (std::is_same::value) + if (std::is_same_v) def = "false"; // Capitalize the first letter of parameter name so it is @@ -118,13 +118,13 @@ template void PrintMethodInit( util::ParamData& d, const size_t indent, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { const std::string prefix(indent, ' '); std::string def = "nil"; - if (std::is_same::value) + if (std::is_same_v) def = "false"; // Capitalize the first letter of parameter name so it is @@ -151,13 +151,13 @@ template void PrintMethodInit( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { const std::string prefix(indent, ' '); std::string def = "nil"; - if (std::is_same::value) + if (std::is_same_v) def = "false"; // Capitalize the first letter of parameter name so it is @@ -193,8 +193,7 @@ void PrintMethodInit(util::ParamData& d, const void* input, void* /* output */) { - PrintMethodInit::type>(d, - *((size_t*) input)); + PrintMethodInit>(d, *((size_t*) input)); } } // namespace go diff --git a/src/mlpack/bindings/go/print_output_processing.hpp b/src/mlpack/bindings/go/print_output_processing.hpp index 563b45125f..90dcdd7b4a 100644 --- a/src/mlpack/bindings/go/print_output_processing.hpp +++ b/src/mlpack/bindings/go/print_output_processing.hpp @@ -29,10 +29,10 @@ template void PrintOutputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { const std::string prefix(indent, ' '); @@ -56,9 +56,9 @@ template void PrintOutputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { const std::string prefix(indent, ' '); @@ -84,8 +84,8 @@ template void PrintOutputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { const std::string prefix(indent, ' '); @@ -111,8 +111,8 @@ template void PrintOutputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Get the type names we need to use. std::string goStrippedType, strippedType, printedType, defaultsType; @@ -144,7 +144,7 @@ void PrintOutputProcessing(util::ParamData& d, const void* /*input*/, void* /* output */) { - PrintOutputProcessing::type>(d, 2); + PrintOutputProcessing>(d, 2); } } // namespace go diff --git a/src/mlpack/bindings/go/print_type_doc.hpp b/src/mlpack/bindings/go/print_type_doc.hpp index b5dde90fa0..4815d15ab2 100644 --- a/src/mlpack/bindings/go/print_type_doc.hpp +++ b/src/mlpack/bindings/go/print_type_doc.hpp @@ -25,11 +25,11 @@ namespace go { template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a vector. @@ -37,7 +37,7 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix option. @@ -45,7 +45,7 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix tuple option. @@ -53,8 +53,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a model. @@ -62,8 +62,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Print the command-line type of an option into a string. @@ -73,8 +73,7 @@ void PrintTypeDoc(util::ParamData& data, const void* /* input */, void* output) { - *((std::string*) output) = - PrintTypeDoc::type>(data); + *((std::string*) output) = PrintTypeDoc>(data); } } // namespace go diff --git a/src/mlpack/bindings/go/print_type_doc_impl.hpp b/src/mlpack/bindings/go/print_type_doc_impl.hpp index 568ef9b059..d97667503c 100644 --- a/src/mlpack/bindings/go/print_type_doc_impl.hpp +++ b/src/mlpack/bindings/go/print_type_doc_impl.hpp @@ -24,29 +24,29 @@ namespace go { template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { // A flag type. - if (std::is_same::value) + if (std::is_same_v) { return "A boolean flag option (`true` or `false`)."; } // An integer. - else if (std::is_same::value) + else if (std::is_same_v) { return "An integer (i.e., `1`)."; } // A floating point value. - else if (std::is_same::value) + else if (std::is_same_v) { return "A floating-point number (i.e., `0.5`)."; } // A string. - else if (std::is_same::value) + else if (std::is_same_v) { return "A character string (i.e., `\"hello\"`)."; } @@ -63,13 +63,13 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same>::value) + if (std::is_same_v>) { return "An array of integers; i.e., `[]int{0, 1, 2}`."; } - else if (std::is_same>::value) + else if (std::is_same_v>) { return "An array of strings; i.e., `[]string{\"hello\", \"goodbye\"}`."; } @@ -85,7 +85,7 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& /* data */, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { if (T::is_col || T::is_row) { @@ -105,8 +105,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& /* data */, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return "A Tuple(matrixWithInfo) containing `float64` data (Data) along with a" " boolean array (Categoricals) indicating which dimensions are categorical" @@ -122,8 +122,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& /* data */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "An mlpack model pointer. This type holds a pointer to C++ memory " "containing the mlpack model. Note that this means the mlpack model " diff --git a/src/mlpack/bindings/julia/default_param.hpp b/src/mlpack/bindings/julia/default_param.hpp index b466d0135a..dc0bb49c2f 100644 --- a/src/mlpack/bindings/julia/default_param.hpp +++ b/src/mlpack/bindings/julia/default_param.hpp @@ -26,13 +26,12 @@ namespace julia { template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>* = 0, + const std::enable_if_t>>* = 0); /** * Return the default value of a vector option. @@ -40,7 +39,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return the default value of a string option. @@ -48,8 +47,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value - >::type* = 0); + const std::enable_if_t>* = 0); /** * Return the default value of a matrix option, a tuple option, a @@ -59,10 +57,10 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value>::type* = 0); + std::is_same_v>>* = 0); /** * Return the default value of a model option (this returns the default @@ -71,8 +69,8 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Return the default value of an option. This is the function that will be @@ -84,7 +82,7 @@ void DefaultParam(util::ParamData& data, void* output) { std::string* outstr = (std::string*) output; - *outstr = DefaultParamImpl::type>(data); + *outstr = DefaultParamImpl>(data); } } // namespace julia diff --git a/src/mlpack/bindings/julia/default_param_impl.hpp b/src/mlpack/bindings/julia/default_param_impl.hpp index 94224814c4..233a2073c8 100644 --- a/src/mlpack/bindings/julia/default_param_impl.hpp +++ b/src/mlpack/bindings/julia/default_param_impl.hpp @@ -24,16 +24,15 @@ namespace julia { template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>*, + const std::enable_if_t>>*) { std::ostringstream oss; - if (std::is_same::value) + if (std::is_same_v) oss << "false"; else oss << std::any_cast(data.value); @@ -47,13 +46,13 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { // Print each element in an array delimited by square brackets. std::ostringstream oss; const T& vector = std::any_cast(data.value); oss << "["; - if (std::is_same>::value) + if (std::is_same_v>) { if (vector.size() > 0) { @@ -90,7 +89,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t>*) { const std::string& s = *std::any_cast(&data.value); return "\"" + s + "\""; @@ -103,23 +102,22 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& /* data */, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value>::type* /* junk */) + std::is_same_v>>* /* junk */) { // Get the filename and return it, or return an empty string. - if (std::is_same::value || - std::is_same::value) + if (std::is_same_v || std::is_same_v) { return "Float64[]"; } - else if (std::is_same>::value || - std::is_same>::value) + else if (std::is_same_v> || + std::is_same_v>) { return "Int[]"; } - else if (std::is_same>::value) + else if (std::is_same_v>) { return "zeros(Int, 0, 0)"; } @@ -135,8 +133,8 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& /* data */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "nothing"; } diff --git a/src/mlpack/bindings/julia/get_julia_type.hpp b/src/mlpack/bindings/julia/get_julia_type.hpp index a3fa2c863a..bf3ceae334 100644 --- a/src/mlpack/bindings/julia/get_julia_type.hpp +++ b/src/mlpack/bindings/julia/get_julia_type.hpp @@ -21,11 +21,11 @@ namespace julia { template inline std::string GetJuliaType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0, + const std::enable_if_t::value>* = 0) { return "unknown_"; // This will cause an error most likely... } @@ -33,11 +33,11 @@ inline std::string GetJuliaType( template<> inline std::string GetJuliaType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*, + const std::enable_if_t::value>*) { return "Bool"; } @@ -45,11 +45,11 @@ inline std::string GetJuliaType( template<> inline std::string GetJuliaType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*, + const std::enable_if_t::value>*) { return "Int"; } @@ -57,11 +57,11 @@ inline std::string GetJuliaType( template<> inline std::string GetJuliaType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*, + const std::enable_if_t::value>*) { return "UInt"; } @@ -69,11 +69,11 @@ inline std::string GetJuliaType( template<> inline std::string GetJuliaType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*, + const std::enable_if_t::value>*) { // I suppose on some systems this may not be 64 bit. return "Float64"; @@ -82,14 +82,11 @@ inline std::string GetJuliaType( template<> inline std::string GetJuliaType( util::ParamData& /* d */, - const typename std::enable_if< - !util::IsStdVector::value>::type*, - const typename std::enable_if< - !arma::is_arma_type::value>::type*, - const typename std::enable_if>::value>::type*, - const typename std::enable_if< - !data::HasSerialize::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*, + const std::enable_if_t::value>*) { return "String"; } @@ -97,10 +94,10 @@ inline std::string GetJuliaType( template inline std::string GetJuliaType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0, + const std::enable_if_t::value>* = 0) { return "Vector{" + GetJuliaType(d) + "}"; } @@ -108,14 +105,14 @@ inline std::string GetJuliaType( template inline std::string GetJuliaType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0, + const std::enable_if_t::value>* = 0) { // size_t matrices are special: we want to represent them in Julia as // Array{Int, X} not UInt because Julia displays UInts strangely. - if (std::is_same::value) + if (std::is_same_v) return std::string("Array{Int, ") + (T::is_col || T::is_row ? "1" : "2") + "}"; else @@ -126,8 +123,8 @@ inline std::string GetJuliaType( template inline std::string GetJuliaType( util::ParamData& /* d */, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { return "Tuple{Array{Bool, 1}, Array{Float64, 2}}"; } @@ -136,9 +133,9 @@ inline std::string GetJuliaType( template inline std::string GetJuliaType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Serializable types are just held as a pointer to nothing, but they're // wrapped in a struct. diff --git a/src/mlpack/bindings/julia/get_printable_param.hpp b/src/mlpack/bindings/julia/get_printable_param.hpp index 99ef72726d..d5d8743652 100644 --- a/src/mlpack/bindings/julia/get_printable_param.hpp +++ b/src/mlpack/bindings/julia/get_printable_param.hpp @@ -25,11 +25,11 @@ namespace julia { template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { std::ostringstream oss; oss << std::any_cast(data.value); @@ -42,7 +42,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { const T& t = std::any_cast(data.value); @@ -58,7 +58,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // Get the matrix. const T& matrix = std::any_cast(data.value); @@ -74,8 +74,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { std::ostringstream oss; oss << data.cppType << " model at " << std::any_cast(data.value); @@ -88,8 +88,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { // Get the matrix. const T& tuple = std::any_cast(data.value); @@ -115,8 +115,7 @@ void GetPrintableParam(util::ParamData& data, const void* /* input */, void* output) { - *((std::string*) output) = - GetPrintableParam::type>(data); + *((std::string*) output) = GetPrintableParam>(data); } } // namespace julia diff --git a/src/mlpack/bindings/julia/get_printable_type.hpp b/src/mlpack/bindings/julia/get_printable_type.hpp index 9fa2a03fec..7a63863864 100644 --- a/src/mlpack/bindings/julia/get_printable_type.hpp +++ b/src/mlpack/bindings/julia/get_printable_type.hpp @@ -23,11 +23,11 @@ namespace julia { template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a vector. @@ -35,7 +35,7 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix option. @@ -43,7 +43,7 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix tuple option. @@ -51,8 +51,8 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a model. @@ -60,8 +60,8 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Print the command-line type of an option into a string. @@ -71,8 +71,7 @@ void GetPrintableType(util::ParamData& data, const void* /* input */, void* output) { - *((std::string*) output) = - GetPrintableType::type>(data); + *((std::string*) output) = GetPrintableType>(data); } } // namespace julia diff --git a/src/mlpack/bindings/julia/get_printable_type_impl.hpp b/src/mlpack/bindings/julia/get_printable_type_impl.hpp index bbf32869b2..dca8dc981e 100644 --- a/src/mlpack/bindings/julia/get_printable_type_impl.hpp +++ b/src/mlpack/bindings/julia/get_printable_type_impl.hpp @@ -26,19 +26,19 @@ namespace julia { template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { - if (std::is_same::value) + if (std::is_same_v) return "Bool"; - else if (std::is_same::value) + else if (std::is_same_v) return "Int"; - else if (std::is_same::value) + else if (std::is_same_v) return "Float64"; - else if (std::is_same::value) + else if (std::is_same_v) return "String"; else throw std::invalid_argument("unknown parameter type " + data.cppType); @@ -50,11 +50,11 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same>::value) + if (std::is_same_v>) return "Array{Int, 1}"; - else if (std::is_same>::value) + else if (std::is_same_v>) return "Array{String, 1}"; else throw std::invalid_argument("unknown vector type " + data.cppType); @@ -66,19 +66,19 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same::value) + if (std::is_same_v) return "Float64 matrix-like"; - else if (std::is_same>::value) + else if (std::is_same_v>) return "Int matrix-like"; - else if (std::is_same::value) + else if (std::is_same_v) return "Float64 vector-like"; - else if (std::is_same>::value) + else if (std::is_same_v>) return "Int vector-like"; - else if (std::is_same::value) + else if (std::is_same_v) return "Float64 vector-like"; - else if (std::is_same>::value) + else if (std::is_same_v>) return "Int vector-like"; else throw std::invalid_argument("unknown Armadillo type " + data.cppType); @@ -90,8 +90,8 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& /* data */, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return "Tuple{Array{Bool, 1}, Array{Float64, 2}}"; } @@ -102,8 +102,8 @@ std::string GetPrintableType( template std::string GetPrintableType( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { std::string type = util::StripType(data.cppType); if (type == "mlpackModel") diff --git a/src/mlpack/bindings/julia/print_input_param.hpp b/src/mlpack/bindings/julia/print_input_param.hpp index 9091747b49..57baeef693 100644 --- a/src/mlpack/bindings/julia/print_input_param.hpp +++ b/src/mlpack/bindings/julia/print_input_param.hpp @@ -39,12 +39,11 @@ void PrintInputParam(util::ParamData& d, // If it's required, then we need the type. if (d.required) { - std::cout << GetJuliaType::type>(d); + std::cout << GetJuliaType>(d); } else { - std::cout << "Union{" - << GetJuliaType::type>(d) + std::cout << "Union{" << GetJuliaType>(d) << ", Missing} = missing"; } } diff --git a/src/mlpack/bindings/julia/print_input_processing.hpp b/src/mlpack/bindings/julia/print_input_processing.hpp index cd19359fd3..1d1a1e8031 100644 --- a/src/mlpack/bindings/julia/print_input_processing.hpp +++ b/src/mlpack/bindings/julia/print_input_processing.hpp @@ -24,10 +24,10 @@ template void PrintInputProcessing( util::ParamData& d, const std::string& functionName, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Print the input processing for an Armadillo type. @@ -36,9 +36,9 @@ template void PrintInputProcessing( util::ParamData& d, const std::string& functionName, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Print the input processing for a serializable type. @@ -47,10 +47,10 @@ template void PrintInputProcessing( util::ParamData& d, const std::string& functionName, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Print the input processing (basically calling params.Get<>()) for a @@ -60,8 +60,8 @@ template void PrintInputProcessing( util::ParamData& d, const std::string& functionName, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Print the input processing (basically calling params.Get<>()) for a type. @@ -72,8 +72,7 @@ void PrintInputProcessing(util::ParamData& d, void* /* output */) { // Call out to the right overload. - PrintInputProcessing::type>(d, - *((std::string*) input)); + PrintInputProcessing>(d, *((std::string*) input)); } } // namespace julia diff --git a/src/mlpack/bindings/julia/print_input_processing_impl.hpp b/src/mlpack/bindings/julia/print_input_processing_impl.hpp index ec9299b540..206cb69414 100644 --- a/src/mlpack/bindings/julia/print_input_processing_impl.hpp +++ b/src/mlpack/bindings/julia/print_input_processing_impl.hpp @@ -27,10 +27,10 @@ template void PrintInputProcessing( util::ParamData& d, const std::string& /* functionName */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { // "type" is a reserved keyword or function. const std::string juliaName = (d.name == "type") ? "type_" : d.name; @@ -66,9 +66,9 @@ template void PrintInputProcessing( util::ParamData& d, const std::string& /* functionName */, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { // "type" is a reserved keyword or function. const std::string juliaName = (d.name == "type") ? "type_" : d.name; @@ -83,7 +83,7 @@ void PrintInputProcessing( // For an Armadillo type, we have to call a different overload for columns and // rows than for regular matrices. - std::string uChar = (std::is_same::value) ? + std::string uChar = (std::is_same_v) ? "U" : ""; std::string indent(extraIndent + 2, ' '); std::string matTypeModifier = ""; @@ -125,10 +125,10 @@ template void PrintInputProcessing( util::ParamData& d, const std::string& functionName, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { // "type" is a reserved keyword or function. const std::string juliaName = (d.name == "type") ? "type_" : d.name; @@ -151,12 +151,12 @@ void PrintInputProcessing( std::string indent(extraIndent + 2, ' '); std::string type = util::StripType(d.cppType); std::cout << indent << "push!(modelPtrs, convert(" - << GetJuliaType::type>(d) << ", " - << juliaName << ").ptr)" << std::endl; + << GetJuliaType>(d) << ", " << juliaName + << ").ptr)" << std::endl; std::cout << indent << functionName << "_internal.SetParam" << type << "(p, \"" << d.name << "\", convert(" - << GetJuliaType::type>(d) << ", " - << juliaName << "))" << std::endl; + << GetJuliaType>(d) << ", " << juliaName + << "))" << std::endl; if (!d.required) { @@ -172,8 +172,8 @@ template void PrintInputProcessing( util::ParamData& d, const std::string& /* functionName */, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { // "type" is a reserved keyword or function. const std::string juliaName = (d.name == "type") ? "type_" : d.name; diff --git a/src/mlpack/bindings/julia/print_model_type_import.hpp b/src/mlpack/bindings/julia/print_model_type_import.hpp index 8b10454750..9630fb05f5 100644 --- a/src/mlpack/bindings/julia/print_model_type_import.hpp +++ b/src/mlpack/bindings/julia/print_model_type_import.hpp @@ -25,8 +25,8 @@ namespace julia { template void PrintModelTypeImport( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Do nothing. } @@ -37,7 +37,7 @@ void PrintModelTypeImport( template void PrintModelTypeImport( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // Do nothing. } @@ -48,8 +48,8 @@ void PrintModelTypeImport( template void PrintModelTypeImport( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // We need to print, e.g., // import .. @@ -67,7 +67,7 @@ void PrintModelTypeImport(util::ParamData& d, const void* /* input */, void* /* output */) { - PrintModelTypeImport::type>(d); + PrintModelTypeImport>(d); } } // namespace julia diff --git a/src/mlpack/bindings/julia/print_output_processing.hpp b/src/mlpack/bindings/julia/print_output_processing.hpp index e4f72ede36..7d94ee2b59 100644 --- a/src/mlpack/bindings/julia/print_output_processing.hpp +++ b/src/mlpack/bindings/julia/print_output_processing.hpp @@ -26,10 +26,10 @@ template void PrintOutputProcessing( util::ParamData& d, const std::string& functionName, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Print the output processing for an Armadillo type. @@ -38,9 +38,9 @@ template void PrintOutputProcessing( util::ParamData& d, const std::string& functionName, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Print the output processing for a serializable type. @@ -49,10 +49,10 @@ template void PrintOutputProcessing( util::ParamData& d, const std::string& functionName, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Print the output processing for a mat/DatasetInfo tuple type. @@ -61,8 +61,8 @@ template void PrintOutputProcessing( util::ParamData& d, const std::string& functionName, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Print the output processing (basically calling params.Get<>()) for a type. @@ -73,8 +73,7 @@ void PrintOutputProcessing(util::ParamData& d, void* /* output */) { // Call out to the right overload. - PrintOutputProcessing::type>(d, - *((std::string*) input)); + PrintOutputProcessing>(d, *((std::string*) input)); } } // namespace julia diff --git a/src/mlpack/bindings/julia/print_output_processing_impl.hpp b/src/mlpack/bindings/julia/print_output_processing_impl.hpp index b3de0f688a..6bfa6e10af 100644 --- a/src/mlpack/bindings/julia/print_output_processing_impl.hpp +++ b/src/mlpack/bindings/julia/print_output_processing_impl.hpp @@ -29,34 +29,34 @@ template void PrintOutputProcessing( util::ParamData& d, const std::string& /* functionName */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { std::string type; - if (std::is_same::value) + if (std::is_same_v) type = "Bool"; - else if (std::is_same::value) + else if (std::is_same_v) type = "Int"; - else if (std::is_same::value) + else if (std::is_same_v) type = "Double"; - else if (std::is_same::value) + else if (std::is_same_v) type = "String"; - else if (std::is_same>::value) + else if (std::is_same_v>) type = "VectorStr"; - else if (std::is_same>::value) + else if (std::is_same_v>) type = "VectorInt"; else type = "Unknown"; // Strings need a little special handling. - if (std::is_same::value) + if (std::is_same_v) std::cout << "Base.unsafe_string("; std::cout << "GetParam" << type << "(p, \"" << d.name << "\")"; - if (std::is_same::value) + if (std::is_same_v) std::cout << ")"; } @@ -67,11 +67,11 @@ template void PrintOutputProcessing( util::ParamData& d, const std::string& /* functionName */, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { - std::string uChar = (std::is_same::value) ? + std::string uChar = (std::is_same_v) ? "U" : ""; std::string matTypeSuffix = ""; std::string extra = ""; @@ -100,10 +100,10 @@ template void PrintOutputProcessing( util::ParamData& d, const std::string& functionName, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { std::string type = util::StripType(d.cppType); std::cout << functionName << "_internal.GetParam" @@ -117,8 +117,8 @@ template void PrintOutputProcessing( util::ParamData& d, const std::string& /* functionName */, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { std::cout << "GetParamMatWithInfo(p, \"" << d.name << "\", juliaOwnedMemory)"; } diff --git a/src/mlpack/bindings/julia/print_param_defn.hpp b/src/mlpack/bindings/julia/print_param_defn.hpp index df862c2aac..c5022875bf 100644 --- a/src/mlpack/bindings/julia/print_param_defn.hpp +++ b/src/mlpack/bindings/julia/print_param_defn.hpp @@ -26,8 +26,8 @@ template void PrintParamDefn( util::ParamData& /* d */, const std::string& /* programName */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Do nothing. } @@ -39,7 +39,7 @@ template void PrintParamDefn( util::ParamData& /* d */, const std::string& /* programName */, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // Do nothing. } @@ -51,8 +51,8 @@ template void PrintParamDefn( util::ParamData& d, const std::string& programName, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // We need to print something of the form below: // @@ -171,8 +171,7 @@ void PrintParamDefn(util::ParamData& d, const void* input, void* /* output */) { - PrintParamDefn::type>(d, - *(std::string*) input); + PrintParamDefn>(d, *(std::string*) input); } } // namespace julia diff --git a/src/mlpack/bindings/julia/print_type_doc.hpp b/src/mlpack/bindings/julia/print_type_doc.hpp index eabda5a067..4acc30c144 100644 --- a/src/mlpack/bindings/julia/print_type_doc.hpp +++ b/src/mlpack/bindings/julia/print_type_doc.hpp @@ -25,11 +25,11 @@ namespace julia { template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a vector. @@ -37,7 +37,7 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix option. @@ -45,7 +45,7 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix tuple option. @@ -53,8 +53,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a model. @@ -62,8 +62,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Print the command-line type of an option into a string. @@ -73,8 +73,7 @@ void PrintTypeDoc(util::ParamData& data, const void* /* input */, void* output) { - *((std::string*) output) = - PrintTypeDoc::type>(data); + *((std::string*) output) = PrintTypeDoc>(data); } } // namespace julia diff --git a/src/mlpack/bindings/julia/print_type_doc_impl.hpp b/src/mlpack/bindings/julia/print_type_doc_impl.hpp index 378147f13c..1f1a5eb971 100644 --- a/src/mlpack/bindings/julia/print_type_doc_impl.hpp +++ b/src/mlpack/bindings/julia/print_type_doc_impl.hpp @@ -24,29 +24,29 @@ namespace julia { template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { // A flag type. - if (std::is_same::value) + if (std::is_same_v) { return "A boolean flag option (`true` or `false`)."; } // An integer. - else if (std::is_same::value) + else if (std::is_same_v) { return "An integer (i.e., `1`)."; } // A floating point value. - else if (std::is_same::value) + else if (std::is_same_v) { return "A floating-point number (i.e., `0.5`)."; } // A string. - else if (std::is_same::value) + else if (std::is_same_v) { return "A character string (i.e., `\"hello\"`)."; } @@ -63,13 +63,13 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same>::value) + if (std::is_same_v>) { return "A vector of integers; i.e., `[0, 1, 2]`."; } - else if (std::is_same>::value) + else if (std::is_same_v>) { return "A vector of strings; i.e., `[\"hello\", \"goodbye\"]`."; } @@ -85,9 +85,9 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same::value) + if (std::is_same_v) { if (T::is_col || T::is_row) { @@ -104,7 +104,7 @@ std::string PrintTypeDoc( "`false` when calling mlpack bindings."; } } - else if (std::is_same::value) + else if (std::is_same_v) { if (T::is_col || T::is_row) { @@ -135,8 +135,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& /* data */, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return "A 2-d array containing `Float64` data along with a boolean array " "indicating which dimensions are categorical (represented by `true`) and " @@ -154,8 +154,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& /* data */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "An mlpack model pointer. `` refers to the type of model that " "is being stored, so, e.g., for `CF()`, the type will be `CFModel`. " diff --git a/src/mlpack/bindings/markdown/default_param.hpp b/src/mlpack/bindings/markdown/default_param.hpp index cf4a175a29..130d89049b 100644 --- a/src/mlpack/bindings/markdown/default_param.hpp +++ b/src/mlpack/bindings/markdown/default_param.hpp @@ -38,27 +38,27 @@ void DefaultParam(util::ParamData& data, if (BindingInfo::Language() == "cli") { *((std::string*) output) = - cli::DefaultParamImpl::type>(data); + cli::DefaultParamImpl>(data); } else if (BindingInfo::Language() == "python") { *((std::string*) output) = - python::DefaultParamImpl::type>(data); + python::DefaultParamImpl>(data); } else if (BindingInfo::Language() == "julia") { *((std::string*) output) = - julia::DefaultParamImpl::type>(data); + julia::DefaultParamImpl>(data); } else if (BindingInfo::Language() == "go") { *((std::string*) output) = - go::DefaultParamImpl::type>(data); + go::DefaultParamImpl>(data); } else if (BindingInfo::Language() == "r") { *((std::string*) output) = - r::DefaultParamImpl::type>(data); + r::DefaultParamImpl>(data); } else { diff --git a/src/mlpack/bindings/markdown/get_printable_param.hpp b/src/mlpack/bindings/markdown/get_printable_param.hpp index 0bc5b37f7c..c3a971fb6f 100644 --- a/src/mlpack/bindings/markdown/get_printable_param.hpp +++ b/src/mlpack/bindings/markdown/get_printable_param.hpp @@ -25,11 +25,11 @@ namespace markdown { template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { std::ostringstream oss; oss << std::any_cast(data.value); @@ -42,7 +42,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { const T& t = std::any_cast(data.value); @@ -58,7 +58,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // Get the matrix. const T& matrix = std::any_cast(data.value); @@ -74,8 +74,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { std::ostringstream oss; oss << data.cppType << " model at " << std::any_cast(data.value); @@ -88,8 +88,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { // Get the matrix. const T& tuple = std::any_cast(data.value); @@ -115,8 +115,7 @@ void GetPrintableParam(util::ParamData& data, const void* /* input */, void* output) { - *((std::string*) output) = - GetPrintableParam::type>(data); + *((std::string*) output) = GetPrintableParam>(data); } } // namespace markdown diff --git a/src/mlpack/bindings/markdown/get_printable_param_name.hpp b/src/mlpack/bindings/markdown/get_printable_param_name.hpp index c222ea10fd..8243b2fcc7 100644 --- a/src/mlpack/bindings/markdown/get_printable_param_name.hpp +++ b/src/mlpack/bindings/markdown/get_printable_param_name.hpp @@ -26,10 +26,10 @@ namespace markdown { template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Get the parameter name for a matrix type (where the user has to pass the file @@ -38,7 +38,7 @@ std::string GetPrintableParamName( template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Get the parameter name for a serializable model type (where the user has to @@ -47,8 +47,8 @@ std::string GetPrintableParamName( template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Get the parameter name for a mapped matrix type (where the user has to pass @@ -57,8 +57,8 @@ std::string GetPrintableParamName( template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Get the parameter's name as seen by the user. @@ -70,7 +70,7 @@ void GetPrintableParamName( void* output) { *((std::string*) output) = - GetPrintableParamName::type>(d); + GetPrintableParamName>(d); } } // namespace markdown diff --git a/src/mlpack/bindings/markdown/get_printable_param_name_impl.hpp b/src/mlpack/bindings/markdown/get_printable_param_name_impl.hpp index b7e9f91fac..41b739692f 100644 --- a/src/mlpack/bindings/markdown/get_printable_param_name_impl.hpp +++ b/src/mlpack/bindings/markdown/get_printable_param_name_impl.hpp @@ -26,10 +26,10 @@ namespace markdown { template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "--" + data.name; } @@ -41,7 +41,7 @@ std::string GetPrintableParamName( template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { return "--" + data.name + "_file"; } @@ -53,8 +53,8 @@ std::string GetPrintableParamName( template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "--" + data.name + "_file"; } @@ -66,8 +66,8 @@ std::string GetPrintableParamName( template std::string GetPrintableParamName( util::ParamData& data, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return "--" + data.name + "_file"; } diff --git a/src/mlpack/bindings/markdown/get_printable_param_value.hpp b/src/mlpack/bindings/markdown/get_printable_param_value.hpp index a0708fc2af..ddaac3e2d9 100644 --- a/src/mlpack/bindings/markdown/get_printable_param_value.hpp +++ b/src/mlpack/bindings/markdown/get_printable_param_value.hpp @@ -27,10 +27,10 @@ template std::string GetPrintableParamValue( util::ParamData& data, const std::string& value, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Get the parameter name for a matrix type (where the user has to pass the file @@ -40,7 +40,7 @@ template std::string GetPrintableParamValue( util::ParamData& data, const std::string& value, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Get the parameter name for a serializable model type (where the user has to @@ -50,8 +50,8 @@ template std::string GetPrintableParamValue( util::ParamData& data, const std::string& value, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Get the parameter name for a mapped matrix type (where the user has to pass @@ -61,8 +61,8 @@ template std::string GetPrintableParamValue( util::ParamData& data, const std::string& value, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Get the parameter's name as seen by the user. @@ -74,7 +74,7 @@ void GetPrintableParamValue( void* output) { *((std::string*) output) = - GetPrintableParamValue::type>(d, + GetPrintableParamValue>(d, *((std::string*) input)); } diff --git a/src/mlpack/bindings/markdown/get_printable_param_value_impl.hpp b/src/mlpack/bindings/markdown/get_printable_param_value_impl.hpp index 0753a7b03e..3c4e6110a6 100644 --- a/src/mlpack/bindings/markdown/get_printable_param_value_impl.hpp +++ b/src/mlpack/bindings/markdown/get_printable_param_value_impl.hpp @@ -28,10 +28,10 @@ template std::string GetPrintableParamValue( util::ParamData& /* data */, const std::string& input, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return input; } @@ -44,7 +44,7 @@ template std::string GetPrintableParamValue( util::ParamData& /* data */, const std::string& input, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { return input + ".csv"; } @@ -57,8 +57,8 @@ template std::string GetPrintableParamValue( util::ParamData& /* data */, const std::string& input, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return input + ".bin"; } @@ -71,8 +71,8 @@ template std::string GetPrintableParamValue( util::ParamData& /* data */, const std::string& input, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return input + ".arff"; } diff --git a/src/mlpack/bindings/markdown/get_printable_type.hpp b/src/mlpack/bindings/markdown/get_printable_type.hpp index 2848947b54..b4316b036a 100644 --- a/src/mlpack/bindings/markdown/get_printable_type.hpp +++ b/src/mlpack/bindings/markdown/get_printable_type.hpp @@ -37,27 +37,27 @@ void GetPrintableType(util::ParamData& data, if (BindingInfo::Language() == "cli") { *((std::string*) output) = - cli::GetPrintableType::type>(data); + cli::GetPrintableType>(data); } else if (BindingInfo::Language() == "python") { *((std::string*) output) = - python::GetPrintableType::type>(data); + python::GetPrintableType>(data); } else if (BindingInfo::Language() == "julia") { *((std::string*) output) = - julia::GetPrintableType::type>(data); + julia::GetPrintableType>(data); } else if (BindingInfo::Language() == "go") { *((std::string*) output) = - go::GetPrintableType::type>(data); + go::GetPrintableType>(data); } else if (BindingInfo::Language() == "r") { *((std::string*) output) = - r::GetPrintableType::type>(data); + r::GetPrintableType>(data); } else { diff --git a/src/mlpack/bindings/markdown/is_serializable.hpp b/src/mlpack/bindings/markdown/is_serializable.hpp index fa66d53f08..bd2c738528 100644 --- a/src/mlpack/bindings/markdown/is_serializable.hpp +++ b/src/mlpack/bindings/markdown/is_serializable.hpp @@ -25,7 +25,7 @@ namespace markdown { */ template bool IsSerializable( - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { return false; } @@ -35,8 +35,8 @@ bool IsSerializable( */ template bool IsSerializable( - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { return true; } @@ -49,7 +49,7 @@ void IsSerializable(util::ParamData& /* data */, const void* /* input */, void* output) { - *((bool*) output) = IsSerializable::type>(); + *((bool*) output) = IsSerializable>(); } } // namespace markdown diff --git a/src/mlpack/bindings/markdown/print_type_doc.hpp b/src/mlpack/bindings/markdown/print_type_doc.hpp index 34a1906fa0..0e4f750979 100644 --- a/src/mlpack/bindings/markdown/print_type_doc.hpp +++ b/src/mlpack/bindings/markdown/print_type_doc.hpp @@ -34,23 +34,23 @@ std::string PrintTypeDoc(util::ParamData& data) { if (BindingInfo::Language() == "cli") { - return cli::PrintTypeDoc::type>(data); + return cli::PrintTypeDoc>(data); } else if (BindingInfo::Language() == "python") { - return python::PrintTypeDoc::type>(data); + return python::PrintTypeDoc>(data); } else if (BindingInfo::Language() == "julia") { - return julia::PrintTypeDoc::type>(data); + return julia::PrintTypeDoc>(data); } else if (BindingInfo::Language() == "go") { - return go::PrintTypeDoc::type>(data); + return go::PrintTypeDoc>(data); } else if (BindingInfo::Language() == "r") { - return r::PrintTypeDoc::type>(data); + return r::PrintTypeDoc>(data); } else { diff --git a/src/mlpack/bindings/python/default_param.hpp b/src/mlpack/bindings/python/default_param.hpp index d7d92283d9..9495949af5 100644 --- a/src/mlpack/bindings/python/default_param.hpp +++ b/src/mlpack/bindings/python/default_param.hpp @@ -26,13 +26,12 @@ namespace python { template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>* = 0, + const std::enable_if_t>>* = 0); /** * Return the default value of a vector option. @@ -40,7 +39,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return the default value of a string option. @@ -48,8 +47,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value - >::type* = 0); + const std::enable_if_t>* = 0); /** * Return the default value of a matrix option, a tuple option, a @@ -59,10 +57,10 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value>::type* = 0); + std::is_same_v>>* = 0); /** * Return the default value of a model option (this returns the default @@ -71,8 +69,8 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Return the default value of an option. This is the function that will be @@ -84,7 +82,7 @@ void DefaultParam(util::ParamData& data, void* output) { std::string* outstr = (std::string*) output; - *outstr = DefaultParamImpl::type>(data); + *outstr = DefaultParamImpl>(data); } } // namespace python diff --git a/src/mlpack/bindings/python/default_param_impl.hpp b/src/mlpack/bindings/python/default_param_impl.hpp index 1e1cab95d5..e318febfc9 100644 --- a/src/mlpack/bindings/python/default_param_impl.hpp +++ b/src/mlpack/bindings/python/default_param_impl.hpp @@ -24,16 +24,15 @@ namespace python { template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>*, + const std::enable_if_t>>*) { std::ostringstream oss; - if (std::is_same::value) + if (std::is_same_v) oss << "False"; else oss << std::any_cast(data.value); @@ -47,13 +46,13 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { // Print each element in an array delimited by square brackets. std::ostringstream oss; const T& vector = std::any_cast(data.value); oss << "["; - if (std::is_same>::value) + if (std::is_same_v>) { if (vector.size() > 0) { @@ -90,7 +89,7 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t>*) { const std::string& s = *std::any_cast(&data.value); return "'" + s + "'"; @@ -103,23 +102,22 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& /* data */, - const typename std::enable_if< + const std::enable_if_t< arma::is_arma_type::value || - std::is_same>::value>::type* /* junk */) + std::is_same_v>>* /* junk */) { // Get the filename and return it, or return an empty string. - if (std::is_same::value || - std::is_same::value) + if (std::is_same_v || std::is_same_v) { return "np.empty([0])"; } - else if (std::is_same>::value || - std::is_same>::value) + else if (std::is_same_v> || + std::is_same_v>) { return "np.empty([0], dtype=np.uint64)"; } - else if (std::is_same>::value) + else if (std::is_same_v>) { return "np.empty([0, 0], dtype=np.uint64)"; } @@ -135,8 +133,8 @@ std::string DefaultParamImpl( template std::string DefaultParamImpl( util::ParamData& /* data */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "None"; } diff --git a/src/mlpack/bindings/python/get_cython_type.hpp b/src/mlpack/bindings/python/get_cython_type.hpp index fd6682832e..5d1b48ad50 100644 --- a/src/mlpack/bindings/python/get_cython_type.hpp +++ b/src/mlpack/bindings/python/get_cython_type.hpp @@ -23,9 +23,9 @@ namespace python { template inline std::string GetCythonType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { return "unknown"; } @@ -33,9 +33,9 @@ inline std::string GetCythonType( template<> inline std::string GetCythonType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "int"; } @@ -43,9 +43,9 @@ inline std::string GetCythonType( template<> inline std::string GetCythonType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "double"; } @@ -53,12 +53,9 @@ inline std::string GetCythonType( template<> inline std::string GetCythonType( util::ParamData& /* d */, - const typename std::enable_if< - !util::IsStdVector::value>::type*, - const typename std::enable_if< - !data::HasSerialize::value>::type*, - const typename std::enable_if< - !arma::is_arma_type::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "string"; } @@ -66,9 +63,9 @@ inline std::string GetCythonType( template<> inline std::string GetCythonType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "size_t"; } @@ -76,9 +73,9 @@ inline std::string GetCythonType( template<> inline std::string GetCythonType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "cbool"; } @@ -86,7 +83,7 @@ inline std::string GetCythonType( template inline std::string GetCythonType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { return "vector[" + GetCythonType(d) + "]"; } @@ -94,7 +91,7 @@ inline std::string GetCythonType( template inline std::string GetCythonType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { std::string type = "Mat"; if (T::is_row) @@ -108,8 +105,8 @@ inline std::string GetCythonType( template inline std::string GetCythonType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { return d.cppType + "*"; } diff --git a/src/mlpack/bindings/python/get_printable_param.hpp b/src/mlpack/bindings/python/get_printable_param.hpp index bfbb386e87..3e205760fb 100644 --- a/src/mlpack/bindings/python/get_printable_param.hpp +++ b/src/mlpack/bindings/python/get_printable_param.hpp @@ -25,11 +25,11 @@ namespace python { template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { std::ostringstream oss; oss << std::any_cast(data.value); @@ -42,7 +42,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { const T& t = std::any_cast(data.value); @@ -58,7 +58,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // Get the matrix. const T& matrix = std::any_cast(data.value); @@ -74,8 +74,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { std::ostringstream oss; oss << data.cppType << " model at " << std::any_cast(data.value); @@ -88,8 +88,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { // Get the matrix. const T& tuple = std::any_cast(data.value); @@ -115,8 +115,7 @@ void GetPrintableParam(util::ParamData& data, const void* /* input */, void* output) { - *((std::string*) output) = - GetPrintableParam::type>(data); + *((std::string*) output) = GetPrintableParam>(data); } } // namespace python diff --git a/src/mlpack/bindings/python/get_printable_type.hpp b/src/mlpack/bindings/python/get_printable_type.hpp index 1d454b172a..8d55a30b92 100644 --- a/src/mlpack/bindings/python/get_printable_type.hpp +++ b/src/mlpack/bindings/python/get_printable_type.hpp @@ -23,95 +23,91 @@ namespace python { template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if< - !util::IsStdVector::value>::type*, - const typename std::enable_if< - !data::HasSerialize::value>::type*, - const typename std::enable_if< - !arma::is_arma_type::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*); + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*); template inline std::string GetPrintableType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); template inline std::string GetPrintableType( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); template void GetPrintableType(util::ParamData& d, const void* /* input */, void* output) { - *((std::string*) output) = - GetPrintableType::type>(d); + *((std::string*) output) = GetPrintableType>(d); } } // namespace python diff --git a/src/mlpack/bindings/python/get_printable_type_impl.hpp b/src/mlpack/bindings/python/get_printable_type_impl.hpp index 5a903af575..cd8851da38 100644 --- a/src/mlpack/bindings/python/get_printable_type_impl.hpp +++ b/src/mlpack/bindings/python/get_printable_type_impl.hpp @@ -22,11 +22,11 @@ namespace python { template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "unknown"; } @@ -34,11 +34,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "int"; } @@ -46,11 +46,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "float"; } @@ -58,14 +58,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if< - !util::IsStdVector::value>::type*, - const typename std::enable_if< - !data::HasSerialize::value>::type*, - const typename std::enable_if< - !arma::is_arma_type::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "str"; } @@ -73,11 +70,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "int"; } @@ -85,11 +82,11 @@ inline std::string GetPrintableType( template<> inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "bool"; } @@ -97,9 +94,9 @@ inline std::string GetPrintableType( template inline std::string GetPrintableType( util::ParamData& d, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return "list of " + GetPrintableType(d) + "s"; } @@ -107,17 +104,17 @@ inline std::string GetPrintableType( template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { std::string type = "matrix"; - if (std::is_same::value) + if (std::is_same_v) { if (T::is_row || T::is_col) type = "vector"; } - else if (std::is_same::value) + else if (std::is_same_v) { type = "int matrix"; if (T::is_row || T::is_col) @@ -130,8 +127,8 @@ inline std::string GetPrintableType( template inline std::string GetPrintableType( util::ParamData& /* d */, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return "categorical matrix"; } @@ -139,10 +136,10 @@ inline std::string GetPrintableType( template inline std::string GetPrintableType( util::ParamData& d, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { return d.cppType + "Type"; } diff --git a/src/mlpack/bindings/python/import_decl.hpp b/src/mlpack/bindings/python/import_decl.hpp index e6518ce461..66edbc388f 100644 --- a/src/mlpack/bindings/python/import_decl.hpp +++ b/src/mlpack/bindings/python/import_decl.hpp @@ -26,8 +26,8 @@ template void ImportDecl( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // First, we have to parse the type. If we have something like, e.g., // 'LogisticRegression<>', we must convert this to 'LogisticRegression[T=*].' @@ -53,8 +53,8 @@ template void ImportDecl( util::ParamData& /* d */, const size_t /* indent */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Print nothing. } @@ -66,7 +66,7 @@ template void ImportDecl( util::ParamData& /* d */, const size_t /* indent */, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // Print nothing. } @@ -84,7 +84,7 @@ void ImportDecl(util::ParamData& d, const void* indent, void* /* output */) { - ImportDecl::type>(d, *((size_t*) indent)); + ImportDecl>(d, *((size_t*) indent)); } } // namespace python diff --git a/src/mlpack/bindings/python/is_serializable.hpp b/src/mlpack/bindings/python/is_serializable.hpp index 83197e87f3..6c014593fc 100644 --- a/src/mlpack/bindings/python/is_serializable.hpp +++ b/src/mlpack/bindings/python/is_serializable.hpp @@ -21,7 +21,7 @@ namespace python { template inline bool IsSerializable( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { return false; } @@ -29,7 +29,7 @@ inline bool IsSerializable( template inline bool IsSerializable( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { return true; } @@ -39,8 +39,7 @@ void IsSerializable(util::ParamData& data, const void* /* input */, void* output) { - *((bool*) output) = - IsSerializable::type>(data); + *((bool*) output) = IsSerializable>(data); } } // namespace python diff --git a/src/mlpack/bindings/python/print_class_defn.hpp b/src/mlpack/bindings/python/print_class_defn.hpp index b3938c4ff1..cd4a0b19a6 100644 --- a/src/mlpack/bindings/python/print_class_defn.hpp +++ b/src/mlpack/bindings/python/print_class_defn.hpp @@ -25,8 +25,8 @@ namespace python { template void PrintClassDefn( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Do nothing. } @@ -37,7 +37,7 @@ void PrintClassDefn( template void PrintClassDefn( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { // Do nothing. } @@ -48,8 +48,8 @@ void PrintClassDefn( template void PrintClassDefn( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // First, we have to parse the type. If we have something like, e.g., // 'LogisticRegression<>', we must convert this to 'LogisticRegression[].' @@ -153,7 +153,7 @@ void PrintClassDefn(util::ParamData& d, const void* /* input */, void* /* output */) { - PrintClassDefn::type>(d); + PrintClassDefn>(d); } } // namespace python diff --git a/src/mlpack/bindings/python/print_defn.hpp b/src/mlpack/bindings/python/print_defn.hpp index 06d1108352..7039510cb5 100644 --- a/src/mlpack/bindings/python/print_defn.hpp +++ b/src/mlpack/bindings/python/print_defn.hpp @@ -32,7 +32,7 @@ void PrintDefn(util::ParamData& d, std::string name = GetValidName(d.name); std::cout << name; - if (std::is_same::value) + if (std::is_same_v) std::cout << "=False"; else if (!d.required) std::cout << "=None"; diff --git a/src/mlpack/bindings/python/print_doc.hpp b/src/mlpack/bindings/python/print_doc.hpp index eaf142b8bc..dfb49fa136 100644 --- a/src/mlpack/bindings/python/print_doc.hpp +++ b/src/mlpack/bindings/python/print_doc.hpp @@ -42,8 +42,7 @@ void PrintDoc(util::ParamData& d, oss << " - "; oss << GetValidName(d.name); oss << " ("; - oss << GetPrintableType::type>(d) << "): " - << d.desc; + oss << GetPrintableType>(d) << "): " << d.desc; // Print a default, if possible. if (!d.required) diff --git a/src/mlpack/bindings/python/print_input_processing.hpp b/src/mlpack/bindings/python/print_input_processing.hpp index 86c163d489..f7a7ab98a8 100644 --- a/src/mlpack/bindings/python/print_input_processing.hpp +++ b/src/mlpack/bindings/python/print_input_processing.hpp @@ -32,11 +32,11 @@ template void PrintInputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { // The copy_all_inputs parameter must be handled first, and therefore is // outside the scope of this code. @@ -46,7 +46,7 @@ void PrintInputProcessing( const std::string prefix(indent, ' '); std::string def = "None"; - if (std::is_same::value) + if (std::is_same_v) def = "False"; // Make sure that we don't use names that are Python keywords. @@ -165,11 +165,11 @@ template void PrintInputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0, + const std::enable_if_t::value>* = 0) { const std::string prefix(indent, ' '); @@ -255,8 +255,8 @@ template void PrintInputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { const std::string prefix(indent, ' '); @@ -383,9 +383,9 @@ template void PrintInputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // First, get the correct class name if needed. std::string strippedType, printedType, defaultsType; @@ -458,9 +458,9 @@ template void PrintInputProcessing( util::ParamData& d, const size_t indent, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { std::string name = GetValidName(d.name); @@ -550,8 +550,7 @@ void PrintInputProcessing(util::ParamData& d, const void* input, void* /* output */) { - PrintInputProcessing::type>(d, - *((size_t*) input)); + PrintInputProcessing>(d, *((size_t*) input)); } } // namespace python diff --git a/src/mlpack/bindings/python/print_output_processing.hpp b/src/mlpack/bindings/python/print_output_processing.hpp index 8082190013..01a1c13b0d 100644 --- a/src/mlpack/bindings/python/print_output_processing.hpp +++ b/src/mlpack/bindings/python/print_output_processing.hpp @@ -31,10 +31,10 @@ void PrintOutputProcessing( util::ParamData& d, const size_t indent, const bool onlyOutput, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0) { const std::string prefix(indent, ' '); @@ -88,7 +88,7 @@ void PrintOutputProcessing( util::ParamData& d, const size_t indent, const bool onlyOutput, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { const std::string prefix(indent, ' '); @@ -129,8 +129,8 @@ void PrintOutputProcessing( util::ParamData& d, const size_t indent, const bool onlyOutput, - const typename std::enable_if>::value>::type* = 0) + const std::enable_if_t>>* = 0) { const std::string prefix(indent, ' '); @@ -171,8 +171,8 @@ void PrintOutputProcessing( util::ParamData& d, const size_t indent, const bool onlyOutput, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Get the type names we need to use. std::string strippedType, printedType, defaultsType; @@ -305,7 +305,7 @@ void PrintOutputProcessing(util::ParamData& d, typedef std::tuple> TupleType; TupleType* tuple = (TupleType*) input; - PrintOutputProcessing::type>( + PrintOutputProcessing>( std::get<0>(*tuple), d, std::get<0>(std::get<1>(*tuple)), std::get<1>(std::get<1>(*tuple))); } diff --git a/src/mlpack/bindings/python/print_type_doc.hpp b/src/mlpack/bindings/python/print_type_doc.hpp index aad90ee4b7..e7981d89f9 100644 --- a/src/mlpack/bindings/python/print_type_doc.hpp +++ b/src/mlpack/bindings/python/print_type_doc.hpp @@ -25,11 +25,11 @@ namespace python { template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a vector. @@ -37,7 +37,7 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix option. @@ -45,7 +45,7 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Return a string representing the command-line type of a matrix tuple option. @@ -53,8 +53,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Return a string representing the command-line type of a model. @@ -62,8 +62,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Print the command-line type of an option into a string. @@ -73,8 +73,7 @@ void PrintTypeDoc(util::ParamData& data, const void* /* input */, void* output) { - *((std::string*) output) = - PrintTypeDoc::type>(data); + *((std::string*) output) = PrintTypeDoc>(data); } } // namespace python diff --git a/src/mlpack/bindings/python/print_type_doc_impl.hpp b/src/mlpack/bindings/python/print_type_doc_impl.hpp index 7e50d24e85..fef2c61b95 100644 --- a/src/mlpack/bindings/python/print_type_doc_impl.hpp +++ b/src/mlpack/bindings/python/print_type_doc_impl.hpp @@ -24,29 +24,29 @@ namespace python { template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { // A flag type. - if (std::is_same::value) + if (std::is_same_v) { return "A boolean flag option (True or False)."; } // An integer. - else if (std::is_same::value) + else if (std::is_same_v) { return "An integer (i.e., \"1\")."; } // A floating point value. - else if (std::is_same::value) + else if (std::is_same_v) { return "A floating-point number (i.e., \"0.5\")."; } // A string. - else if (std::is_same::value) + else if (std::is_same_v) { return "A character string (i.e., \"hello\")."; } @@ -63,13 +63,13 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same>::value) + if (std::is_same_v>) { return "A list of integers; i.e., `[0, 1, 2]`."; } - else if (std::is_same>::value) + else if (std::is_same_v>) { return "A list of strings; i.e., `[\"hello\", \"goodbye\"]`."; } @@ -85,9 +85,9 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { - if (std::is_same::value) + if (std::is_same_v) { if (T::is_col || T::is_row) { @@ -103,7 +103,7 @@ std::string PrintTypeDoc( "float64, it will be converted."; } } - else if (std::is_same::value) + else if (std::is_same_v) { if (T::is_col || T::is_row) { @@ -131,8 +131,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& /* data */, - const typename std::enable_if>::value>::type*) + const std::enable_if_t>>*) { return "A 2-d arraylike containing data. Like the regular 2-d matrices, this" " can be a list of lists, a numpy ndarray, or a pandas DataFrame. " @@ -150,8 +150,8 @@ std::string PrintTypeDoc( template std::string PrintTypeDoc( util::ParamData& /* data */, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { return "An mlpack model pointer. This type can be pickled to or from disk, " "and internally holds a pointer to C++ memory containing the mlpack " diff --git a/src/mlpack/bindings/tests/delete_allocated_memory.hpp b/src/mlpack/bindings/tests/delete_allocated_memory.hpp index 033a7527a0..e882159b45 100644 --- a/src/mlpack/bindings/tests/delete_allocated_memory.hpp +++ b/src/mlpack/bindings/tests/delete_allocated_memory.hpp @@ -21,8 +21,8 @@ namespace tests { template void DeleteAllocatedMemoryImpl( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Do nothing. } @@ -30,7 +30,7 @@ void DeleteAllocatedMemoryImpl( template void DeleteAllocatedMemoryImpl( util::ParamData& d, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { (*std::any_cast(&d.value)).clear(); } @@ -38,8 +38,8 @@ void DeleteAllocatedMemoryImpl( template void DeleteAllocatedMemoryImpl( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Delete the allocated memory (hopefully we actually own it). delete *std::any_cast(&d.value); @@ -51,7 +51,7 @@ void DeleteAllocatedMemory( const void* /* input */, void* /* output */) { - DeleteAllocatedMemoryImpl::type>(d); + DeleteAllocatedMemoryImpl>(d); } } // namespace tests diff --git a/src/mlpack/bindings/tests/get_allocated_memory.hpp b/src/mlpack/bindings/tests/get_allocated_memory.hpp index fc936c48d9..903b17420f 100644 --- a/src/mlpack/bindings/tests/get_allocated_memory.hpp +++ b/src/mlpack/bindings/tests/get_allocated_memory.hpp @@ -22,8 +22,8 @@ namespace tests { template void* GetAllocatedMemory( util::ParamData& /* d */, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { return NULL; } @@ -31,7 +31,7 @@ void* GetAllocatedMemory( template void* GetAllocatedMemory( util::ParamData& d, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0) { return (*std::any_cast(&d.value)).memptr(); } @@ -39,8 +39,8 @@ void* GetAllocatedMemory( template void* GetAllocatedMemory( util::ParamData& d, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0) { // Here we have a model; return its memory location. return *std::any_cast(&d.value); @@ -51,8 +51,7 @@ void GetAllocatedMemory(util::ParamData& d, const void* /* input */, void* output) { - *((void**) output) = - GetAllocatedMemory::type>(d); + *((void**) output) = GetAllocatedMemory>(d); } } // namespace tests diff --git a/src/mlpack/bindings/tests/get_printable_param.hpp b/src/mlpack/bindings/tests/get_printable_param.hpp index 0bf5e2ff24..bb72dd93a2 100644 --- a/src/mlpack/bindings/tests/get_printable_param.hpp +++ b/src/mlpack/bindings/tests/get_printable_param.hpp @@ -27,11 +27,11 @@ namespace tests { template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0, + const std::enable_if_t>>* = 0); /** * Print a vector option, with spaces between it. @@ -39,7 +39,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Print a matrix option (this just prints the filename). @@ -47,7 +47,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0); /** * Print a serializable class option (this just prints the filename). @@ -55,8 +55,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type* = 0, - const typename std::enable_if::value>::type* = 0); + const std::enable_if_t::value>* = 0, + const std::enable_if_t::value>* = 0); /** * Print a mapped matrix option (this just prints the filename). @@ -64,8 +64,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if>::value>::type* = 0); + const std::enable_if_t>>* = 0); /** * Print an option into a std::string. This should print a short, one-line @@ -77,8 +77,7 @@ void GetPrintableParam(util::ParamData& data, const void* /* input */, void* output) { - *((std::string*) output) = - GetPrintableParam::type>(data); + *((std::string*) output) = GetPrintableParam>(data); } } // namespace tests diff --git a/src/mlpack/bindings/tests/get_printable_param_impl.hpp b/src/mlpack/bindings/tests/get_printable_param_impl.hpp index c800a0aa7a..5015fffca3 100644 --- a/src/mlpack/bindings/tests/get_printable_param_impl.hpp +++ b/src/mlpack/bindings/tests/get_printable_param_impl.hpp @@ -22,11 +22,11 @@ namespace tests { template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*, - const typename std::enable_if>::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t::value>*, + const std::enable_if_t>>*) { std::ostringstream oss; oss << std::any_cast(data.value); @@ -37,7 +37,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { const T& t = std::any_cast(data.value); @@ -51,7 +51,7 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& /* data */, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*) { return "matrix type"; } @@ -60,8 +60,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& data, - const typename std::enable_if::value>::type*, - const typename std::enable_if::value>::type*) + const std::enable_if_t::value>*, + const std::enable_if_t::value>*) { // Extract the string from the tuple that's being held. std::ostringstream oss; @@ -73,8 +73,8 @@ std::string GetPrintableParam( template std::string GetPrintableParam( util::ParamData& /* data */, - const typename std::enable_if>::value>::type* /* junk */) + const std::enable_if_t>>* /* junk */) { return "matrix/DatatsetInfo tuple"; } diff --git a/src/mlpack/core/cereal/is_loading.hpp b/src/mlpack/core/cereal/is_loading.hpp index 085358b2f4..f6346abfce 100644 --- a/src/mlpack/core/cereal/is_loading.hpp +++ b/src/mlpack/core/cereal/is_loading.hpp @@ -28,26 +28,24 @@ struct is_cereal_archive { // Archive::is_loading is not implemented yet, so we can use std::is_same<> // to check if it is a loading archive. - constexpr static bool value = std::is_same::value || + constexpr static bool value = std::is_same_v || // #if (BINDING_TYPE != BINDING_TYPE_R) - std::is_same::value || + std::is_same_v || // #endif - std::is_same::value; + std::is_same_v; }; template bool is_loading( - const typename std::enable_if< - is_cereal_archive::value, Archive>::type* = 0) + const std::enable_if_t::value, Archive>* = 0) { return true; } template bool is_loading( - const typename std::enable_if< - !is_cereal_archive::value, Archive>::type* = 0) + const std::enable_if_t::value, Archive>* = 0) { return false; } diff --git a/src/mlpack/core/cereal/is_saving.hpp b/src/mlpack/core/cereal/is_saving.hpp index e54362913f..6a23333a7f 100644 --- a/src/mlpack/core/cereal/is_saving.hpp +++ b/src/mlpack/core/cereal/is_saving.hpp @@ -29,26 +29,26 @@ struct is_cereal_archive_saving { // Archive::is_saving is not implemented yet, so we can use std::is_same<> // to check if it is a loading archive. - constexpr static bool value = std::is_same::value || + constexpr static bool value = std::is_same_v || // #if (BINDING_TYPE != BINDING_TYPE_R) - std::is_same::value || + std::is_same_v || // #endif - std::is_same::value; + std::is_same_v; }; template bool is_saving( - const typename std::enable_if< - is_cereal_archive_saving::value, Archive>::type* = 0) + const std::enable_if_t< + is_cereal_archive_saving::value, Archive>* = 0) { return true; } template bool is_saving( - const typename std::enable_if< - !is_cereal_archive_saving::value, Archive>::type* = 0) + const std::enable_if_t< + !is_cereal_archive_saving::value, Archive>* = 0) { return false; } diff --git a/src/mlpack/core/cv/cv_base.hpp b/src/mlpack/core/cv/cv_base.hpp index 02166eb4e0..1ca40368ff 100644 --- a/src/mlpack/core/cv/cv_base.hpp +++ b/src/mlpack/core/cv/cv_base.hpp @@ -126,7 +126,7 @@ class CVBase */ template::type> + typename = std::enable_if_t> MLAlgorithm TrainModel(const MatType& xs, const PredictionsType& ys, const MLAlgorithmArgs&... args); @@ -137,7 +137,7 @@ class CVBase */ template::type, + typename = std::enable_if_t, typename = void> MLAlgorithm TrainModel(const MatType& xs, const PredictionsType& ys, @@ -149,7 +149,7 @@ class CVBase */ template::type, + typename = std::enable_if_t, typename = void, typename = void> MLAlgorithm TrainModel(const MatType& xs, @@ -162,7 +162,7 @@ class CVBase */ template::type> + typename = std::enable_if_t> MLAlgorithm TrainModel(const MatType& xs, const PredictionsType& ys, const WeightsType& weights, @@ -174,7 +174,7 @@ class CVBase */ template::type, + typename = std::enable_if_t, typename = void> MLAlgorithm TrainModel(const MatType& xs, const PredictionsType& ys, @@ -187,7 +187,7 @@ class CVBase */ template::type, + typename = std::enable_if_t, typename = void, typename = void> MLAlgorithm TrainModel(const MatType& xs, @@ -206,8 +206,7 @@ class CVBase */ template::type> + typename = std::enable_if_t> MLAlgorithm TrainModel(const MatType& xs, const PredictionsType& ys, const MLAlgorithmArgs&... args); @@ -218,8 +217,7 @@ class CVBase */ template::type, + typename = std::enable_if_t, typename = void> MLAlgorithm TrainModel(const MatType& xs, const PredictionsType& ys, diff --git a/src/mlpack/core/cv/cv_base_impl.hpp b/src/mlpack/core/cv/cv_base_impl.hpp index d5e5acc7b0..33d48a68cb 100644 --- a/src/mlpack/core/cv/cv_base_impl.hpp +++ b/src/mlpack/core/cv/cv_base_impl.hpp @@ -141,8 +141,8 @@ MLAlgorithm CVBase::value, + std::is_constructible_v, "The given MLAlgorithm is not constructible from the passed arguments"); return MLAlgorithm(xs, ys, args...); @@ -161,8 +161,9 @@ MLAlgorithm CVBase::value, + std::is_constructible_v, "The given MLAlgorithm is not constructible from the passed arguments"); return MLAlgorithm(xs, ys, numClasses, args...); @@ -182,15 +183,16 @@ MLAlgorithm CVBase::value, + MLAlgorithmArgs...>, "The given MLAlgorithm is not constructible with a data::DatasetInfo " "parameter and the passed arguments"); static const bool constructableWithoutDatasetInfo = - std::is_constructible::value; + std::is_constructible_v; return TrainModel(xs, ys, args...); } @@ -208,8 +210,9 @@ MLAlgorithm CVBase::value, + std::is_constructible_v, "The given MLAlgorithm is not constructible from the passed arguments"); return MLAlgorithm(xs, ys, weights, args...); @@ -229,8 +232,9 @@ MLAlgorithm CVBase::value, + std::is_constructible_v, "The given MLAlgorithm is not constructible from the passed arguments"); return MLAlgorithm(xs, ys, numClasses, weights, args...); @@ -251,15 +255,16 @@ MLAlgorithm CVBase::value, + const WeightsType&, MLAlgorithmArgs...>, "The given MLAlgorithm is not constructible with a data::DatasetInfo " "parameter and the passed arguments"); static const bool constructableWithoutDatasetInfo = - std::is_constructible::value; + std::is_constructible_v; return TrainModel(xs, ys, weights, args...); } diff --git a/src/mlpack/core/cv/k_fold_cv.hpp b/src/mlpack/core/cv/k_fold_cv.hpp index 652975cbaf..3538236180 100644 --- a/src/mlpack/core/cv/k_fold_cv.hpp +++ b/src/mlpack/core/cv/k_fold_cv.hpp @@ -189,7 +189,7 @@ class KFoldCV * the model type. */ template::type> + typename = std::enable_if_t> void Shuffle(); /** @@ -197,7 +197,7 @@ class KFoldCV * model type. */ template::type, + typename = std::enable_if_t, typename = void> void Shuffle(); @@ -257,7 +257,7 @@ class KFoldCV */ template::type> + typename = std::enable_if_t> double TrainAndEvaluate(const MLAlgorithmArgs& ...mlAlgorithmArgs); /** @@ -265,7 +265,7 @@ class KFoldCV */ template::type, + typename = std::enable_if_t, typename = void> double TrainAndEvaluate(const MLAlgorithmArgs& ...mlAlgorithmArgs); diff --git a/src/mlpack/core/cv/meta_info_extractor.hpp b/src/mlpack/core/cv/meta_info_extractor.hpp index 936501da40..704bb62842 100644 --- a/src/mlpack/core/cv/meta_info_extractor.hpp +++ b/src/mlpack/core/cv/meta_info_extractor.hpp @@ -217,11 +217,11 @@ struct SelectMethodForm template struct Implementation { - using Type = typename std::conditional< + using Type = std::conditional_t< HasMethodForm::value, Form, - typename Implementation::Type>::type; + typename Implementation::Type>; }; public: @@ -305,9 +305,9 @@ class MetaInfoExtractor /* An indication whether a method form is selected */ template - using Selects = typename std::conditional< - std::is_same::Type, NotFoundMethodForm>::value, - std::false_type, std::true_type>::type; + using Selects = std::conditional_t< + std::is_same_v::Type, NotFoundMethodForm>, + std::false_type, std::true_type>; public: /** @@ -328,12 +328,12 @@ class MetaInfoExtractor * An indication whether PredictionsType has been identified (i.e. MLAlgorithm * is supported by MetaInfoExtractor). */ - static const bool IsSupported = !std::is_same::value; + static const bool IsSupported = !std::is_same_v; /** * An indication whether MLAlgorithm supports weighted learning. */ - static const bool SupportsWeights = !std::is_same::value; + static const bool SupportsWeights = !std::is_same_v; /** * An indication whether MLAlgorithm takes a data::DatasetInfo parameter. diff --git a/src/mlpack/core/cv/simple_cv.hpp b/src/mlpack/core/cv/simple_cv.hpp index fa2c985b86..573b6006ce 100644 --- a/src/mlpack/core/cv/simple_cv.hpp +++ b/src/mlpack/core/cv/simple_cv.hpp @@ -289,7 +289,7 @@ class SimpleCV */ template::type> + typename = std::enable_if_t> double TrainAndEvaluate(const MLAlgorithmArgs&... args); /** @@ -297,7 +297,7 @@ class SimpleCV */ template::type, + typename = std::enable_if_t, typename = void> double TrainAndEvaluate(const MLAlgorithmArgs&... args); }; diff --git a/src/mlpack/core/data/dataset_mapper_impl.hpp b/src/mlpack/core/data/dataset_mapper_impl.hpp index 7422adc673..46c8c61ca9 100644 --- a/src/mlpack/core/data/dataset_mapper_impl.hpp +++ b/src/mlpack/core/data/dataset_mapper_impl.hpp @@ -52,7 +52,7 @@ void CallMapFirstPass( const InputType& input, const size_t dimension, std::vector& types, - const typename std::enable_if::type* = 0) + const std::enable_if_t* = 0) { policy.template MapFirstPass(input, dimension, types); } @@ -64,7 +64,7 @@ void CallMapFirstPass( const InputType& /* input */, const size_t /* dimension */, std::vector& /* types */, - const typename std::enable_if::type* = 0) + const std::enable_if_t* = 0) { // Nothing to do here. } diff --git a/src/mlpack/core/data/has_serialize.hpp b/src/mlpack/core/data/has_serialize.hpp index 7c2c3d114a..8eee0813ce 100644 --- a/src/mlpack/core/data/has_serialize.hpp +++ b/src/mlpack/core/data/has_serialize.hpp @@ -52,7 +52,7 @@ struct HasSerialize template struct check; template static yes& chk( // This matches classes. check::value>*, + typename std::enable_if_t>*, typename std::enable_if_t::value>*>*); template static no& chk(...); // This matches non-classes. diff --git a/src/mlpack/core/data/load_numeric_csv.hpp b/src/mlpack/core/data/load_numeric_csv.hpp index 7fba6e6498..c8bfdb3735 100644 --- a/src/mlpack/core/data/load_numeric_csv.hpp +++ b/src/mlpack/core/data/load_numeric_csv.hpp @@ -24,7 +24,7 @@ namespace data { template inline eT SafeNegInf( const bool neg, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t>* = 0) { // For an unsigned type, we cannot return negative infinity, so instead return // 0. @@ -34,7 +34,7 @@ inline eT SafeNegInf( template inline eT SafeNegInf( const bool neg, - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t>* = 0) { return neg ? -(std::numeric_limits::infinity()) : std::numeric_limits::infinity(); @@ -88,13 +88,13 @@ bool LoadCSV::ConvertToken(eT& val, // Convert the token into correct type. // If we have a eT as unsigned int, // it will convert all negative numbers to 0. - if (std::is_floating_point::value) + if (std::is_floating_point_v) { val = eT(std::strtod(str, &endptr)); } - else if (std::is_integral::value) + else if (std::is_integral_v) { - if (std::is_signed::value) + if (std::is_signed_v) val = eT(std::strtoll(str, &endptr, 10)); else { diff --git a/src/mlpack/core/data/string_encoding.hpp b/src/mlpack/core/data/string_encoding.hpp index 95067de79f..8edc498d5b 100644 --- a/src/mlpack/core/data/string_encoding.hpp +++ b/src/mlpack/core/data/string_encoding.hpp @@ -198,8 +198,8 @@ class StringEncoding std::vector>& output, const TokenizerType& tokenizer, PolicyType& policy, - typename std::enable_if::onePassEncoding>::type* = 0); + std::enable_if_t::onePassEncoding>* = 0); private: //! The encoding policy object. diff --git a/src/mlpack/core/data/string_encoding_impl.hpp b/src/mlpack/core/data/string_encoding_impl.hpp index cee7a5665f..764fbae11a 100644 --- a/src/mlpack/core/data/string_encoding_impl.hpp +++ b/src/mlpack/core/data/string_encoding_impl.hpp @@ -70,9 +70,9 @@ void StringEncoding::CreateMap( auto token = tokenizer(strView); static_assert( - std::is_same::type, - typename std::remove_reference::type>::value, + std::is_same_v, + std::remove_reference_t>, "The dictionary token type doesn't match the return value type " "of the tokenizer."); @@ -116,9 +116,9 @@ EncodeHelper(const std::vector& input, auto token = tokenizer(strView); static_assert( - std::is_same::type, - typename std::remove_reference::type>::value, + std::is_same_v, + std::remove_reference_t>, "The dictionary token type doesn't match the return value type " "of the tokenizer."); @@ -163,8 +163,8 @@ EncodeHelper(const std::vector& input, std::vector>& output, const TokenizerType& tokenizer, PolicyType& policy, - typename std::enable_if::onePassEncoding>::type*) + std::enable_if_t::onePassEncoding>*) { policy.Reset(); @@ -176,9 +176,9 @@ EncodeHelper(const std::vector& input, auto token = tokenizer(strView); static_assert( - std::is_same::type, - typename std::remove_reference::type>::value, + std::is_same_v, + std::remove_reference_t>, "The dictionary token type doesn't match the return value type " "of the tokenizer."); diff --git a/src/mlpack/core/distributions/discrete_distribution.hpp b/src/mlpack/core/distributions/discrete_distribution.hpp index 3821cafa72..c309ece04d 100644 --- a/src/mlpack/core/distributions/discrete_distribution.hpp +++ b/src/mlpack/core/distributions/discrete_distribution.hpp @@ -153,7 +153,7 @@ class DiscreteDistribution { // Adding 0.5 helps ensure that we cast the floating point to a size_t // correctly. - const size_t obs = (std::is_floating_point::value) ? + const size_t obs = (std::is_floating_point_v) ? size_t(observation(dimension) + 0.5) : size_t(observation(dimension)); // Ensure that the observation is within the bounds. diff --git a/src/mlpack/core/distributions/discrete_distribution_impl.hpp b/src/mlpack/core/distributions/discrete_distribution_impl.hpp index 360c382a94..1c232501be 100644 --- a/src/mlpack/core/distributions/discrete_distribution_impl.hpp +++ b/src/mlpack/core/distributions/discrete_distribution_impl.hpp @@ -83,7 +83,7 @@ inline void DiscreteDistribution::Train( // Add the probability of each observation. The addition of 0.5 to the // observation is to turn the default flooring operation of the size_t // cast into a rounding observation. - const size_t obs = (std::is_floating_point::value) ? + const size_t obs = (std::is_floating_point_v) ? size_t(observations(i, r) + 0.5) : size_t(observations(i, r)); // Ensure that the observation is within the bounds. @@ -141,7 +141,7 @@ inline void DiscreteDistribution::Train( // Add the probability of each observation. The addition of 0.5 // to the observation is to turn the default flooring operation // of the size_t cast into a rounding observation. - const size_t obs = (std::is_floating_point::value) ? + const size_t obs = (std::is_floating_point_v) ? size_t(observations(i, r) + 0.5) : size_t(observations(i, r)); // Ensure that the observation is within the bounds. diff --git a/src/mlpack/core/distributions/gamma_distribution.hpp b/src/mlpack/core/distributions/gamma_distribution.hpp index b1b8079a99..f9364b3899 100644 --- a/src/mlpack/core/distributions/gamma_distribution.hpp +++ b/src/mlpack/core/distributions/gamma_distribution.hpp @@ -75,7 +75,7 @@ class GammaDistribution */ GammaDistribution(const MatType& data, const ElemType tol = - std::is_same::value ? 1e-4 : 1e-8); + std::is_same_v ? 1e-4 : 1e-8); /** * Construct the Gamma distribution given two vectors alpha and beta. @@ -101,7 +101,7 @@ class GammaDistribution */ void Train(const MatType& rdata, const ElemType tol = - std::is_same::value ? 1e-4 : 1e-8); + std::is_same_v ? 1e-4 : 1e-8); /** * Fits an alpha and beta parameter according to observation probabilities. @@ -117,7 +117,7 @@ class GammaDistribution void Train(const MatType& observations, const VecType& probabilities, const ElemType tol = - std::is_same::value ? 1e-4 : 1e-8); + std::is_same_v ? 1e-4 : 1e-8); /** * This function trains (fits distribution parameters) to a dataset with @@ -136,7 +136,7 @@ class GammaDistribution const VecType& meanLogxVec, const VecType& meanxVec, const ElemType tol = - std::is_same::value ? 1e-4 : 1e-8); + std::is_same_v ? 1e-4 : 1e-8); /** * This function returns the probability of a group of observations. diff --git a/src/mlpack/core/hpt/cv_function.hpp b/src/mlpack/core/hpt/cv_function.hpp index 9fef73a7a4..90dd1da5c5 100644 --- a/src/mlpack/core/hpt/cv_function.hpp +++ b/src/mlpack/core/hpt/cv_function.hpp @@ -130,8 +130,8 @@ class CVFunction template::type> + typename = + std::enable_if_t<(BoundArgIndex + ParamIndex < TotalArgs)>> inline double Evaluate(const arma::mat& parameters, const Args&... args); /** @@ -140,8 +140,8 @@ class CVFunction template::type, + typename = + std::enable_if_t, typename = void> inline double Evaluate(const arma::mat& parameters, const Args&... args); @@ -151,8 +151,8 @@ class CVFunction template::value>::type> + typename = std::enable_if_t< + UseBoundArg::value>> inline double PutNextArg(const arma::mat& parameters, const Args&... args); /** @@ -162,8 +162,8 @@ class CVFunction template::value>::type, + typename = std::enable_if_t< + !UseBoundArg::value>, typename = void> inline double PutNextArg(const arma::mat& parameters, const Args&... args); }; diff --git a/src/mlpack/core/hpt/deduce_hp_types.hpp b/src/mlpack/core/hpt/deduce_hp_types.hpp index d48c9da280..e4f0e903f6 100644 --- a/src/mlpack/core/hpt/deduce_hp_types.hpp +++ b/src/mlpack/core/hpt/deduce_hp_types.hpp @@ -51,7 +51,7 @@ struct DeduceHyperParameterTypes * A type function to deduce the result hyper-parameter type for ArgumentType. */ template::value> + bool IsArithmetic = std::is_arithmetic_v> struct ResultHPType; template diff --git a/src/mlpack/core/hpt/fixed.hpp b/src/mlpack/core/hpt/fixed.hpp index d8f6a3df35..55bf2adc6b 100644 --- a/src/mlpack/core/hpt/fixed.hpp +++ b/src/mlpack/core/hpt/fixed.hpp @@ -101,7 +101,7 @@ class IsPreFixedArg struct Implementation> : std::true_type {}; public: - static const bool value = Implementation::type>::value; + static const bool value = Implementation>::value; }; } // namespace mlpack diff --git a/src/mlpack/core/hpt/hpt.hpp b/src/mlpack/core/hpt/hpt.hpp index c9d8dee829..fdfc237f9f 100644 --- a/src/mlpack/core/hpt/hpt.hpp +++ b/src/mlpack/core/hpt/hpt.hpp @@ -199,10 +199,9 @@ class HyperParameterTuner }; //! A short alias for the full type of the cross-validation. - using CVType = typename std::conditional, - CV, MatType, PredictionsType, - WeightsType>>::type; + CV, MatType, PredictionsType, WeightsType>>; //! The cross-validation object for assessing sets of hyper-parameters. @@ -234,15 +233,15 @@ class HyperParameterTuner * PreFixedArg. */ template - using IsPreFixed = IsPreFixedArg::type>; + using IsPreFixed = IsPreFixedArg>; /** * A type function to check whether the element I of the tuple type is an * arithmetic type. */ template - using IsArithmetic = std::is_arithmetic::type>::type>; + using IsArithmetic = std::is_arithmetic>>; /** * The set of methods to initialize auxiliary objects (a CVFunction object and diff --git a/src/mlpack/core/hpt/hpt_impl.hpp b/src/mlpack/core/hpt/hpt_impl.hpp index 596f58e0ab..019598c09c 100644 --- a/src/mlpack/core/hpt/hpt_impl.hpp +++ b/src/mlpack/core/hpt/hpt_impl.hpp @@ -130,8 +130,8 @@ void HyperParameterTuner& datasetInfo, FixedArgs... fixedArgs) { - using PreFixedArgT = typename std::remove_reference< - typename std::tuple_element::type>::type; + using PreFixedArgT = std::remove_reference_t< + std::tuple_element_t>; using FixedArgT = FixedArg; InitAndOptimize(args, bestParams, datasetInfo, fixedArgs..., diff --git a/src/mlpack/core/math/digamma.hpp b/src/mlpack/core/math/digamma.hpp index 3a252ce5db..ecb1be9a41 100644 --- a/src/mlpack/core/math/digamma.hpp +++ b/src/mlpack/core/math/digamma.hpp @@ -27,7 +27,7 @@ namespace mlpack { * @param x Input for which digamma will be calculated. */ template -typename std::enable_if::type +std::enable_if_t EvaluatePolyLarge(const T(&a)[N], const T& x) { T x2 = x * x; @@ -60,7 +60,7 @@ EvaluatePolyLarge(const T(&a)[N], const T& x) * @param x Input for which digamma will be calculated. */ template -typename std::enable_if::type +std::enable_if_t EvaluatePoly12(const T(&a)[N], const T& x) { T x2 = x * x; @@ -91,7 +91,7 @@ EvaluatePoly12(const T(&a)[N], const T& x) * @param x Input for which digamma will be calculated. */ template -typename std::enable_if::type +std::enable_if_t EvaluatePoly12(const T(&a)[N], const T& x) { T x2 = x * x; diff --git a/src/mlpack/core/math/trigamma.hpp b/src/mlpack/core/math/trigamma.hpp index 5cab44654d..70a6a1910b 100644 --- a/src/mlpack/core/math/trigamma.hpp +++ b/src/mlpack/core/math/trigamma.hpp @@ -30,7 +30,7 @@ namespace mlpack { * @param x Input for which we have to calculate trigamma. */ template -typename std::enable_if::type +std::enable_if_t EvaluatePolyPrec(const T(&a)[N], const T& x) { T x2 = x * x; @@ -60,7 +60,7 @@ EvaluatePolyPrec(const T(&a)[N], const T& x) * @param x Input for which we have to calculate trigamma. */ template -typename std::enable_if::type +std::enable_if_t EvaluatePolyPrec(const T(&a)[N], const T& x) { T x2 = x * x; diff --git a/src/mlpack/core/tree/address.hpp b/src/mlpack/core/tree/address.hpp index bd3b6c3538..e2e4250887 100644 --- a/src/mlpack/core/tree/address.hpp +++ b/src/mlpack/core/tree/address.hpp @@ -56,12 +56,12 @@ void PointToAddress(AddressType& address, const VecType& point) { typedef typename VecType::elem_type VecElemType; // Check that the arguments are compatible. - typedef typename std::conditional::type AddressElemType; + uint64_t> AddressElemType; - static_assert(std::is_same::value == true, "The vector element type does not " + static_assert(std::is_same_v == true, "The vector element type does not " "correspond to the address element type."); arma::Col result(point.n_elem); @@ -152,12 +152,12 @@ void AddressToPoint(VecType& point, const AddressType& address) { typedef typename VecType::elem_type VecElemType; // Check that the arguments are compatible. - typedef typename std::conditional::type AddressElemType; + uint64_t> AddressElemType; - static_assert(std::is_same::value == true, "The vector element type does not " + static_assert(std::is_same_v == true, "The vector element type does not " "correspond to the address element type."); constexpr size_t order = sizeof(AddressElemType) * CHAR_BIT; @@ -230,8 +230,8 @@ void AddressToPoint(VecType& point, const AddressType& address) template int CompareAddresses(const AddressType1& addr1, const AddressType2& addr2) { - static_assert(std::is_same::value == true, "Can't compare " + static_assert(std::is_same_v == true, "Can't compare " "addresses of distinct types"); assert(addr1.n_elem == addr2.n_elem); diff --git a/src/mlpack/core/tree/binary_space_tree/typedef.hpp b/src/mlpack/core/tree/binary_space_tree/typedef.hpp index 7a5eca8edf..871438c8db 100644 --- a/src/mlpack/core/tree/binary_space_tree/typedef.hpp +++ b/src/mlpack/core/tree/binary_space_tree/typedef.hpp @@ -198,7 +198,9 @@ template using VPTreeSplit = VantagePointSplit; -template +template using VPTree = BinarySpaceTree::type AddressElemType; + uint64_t> AddressElemType; //! An information about the partition. struct SplitInfo diff --git a/src/mlpack/core/tree/binary_space_tree/vantage_point_split_impl.hpp b/src/mlpack/core/tree/binary_space_tree/vantage_point_split_impl.hpp index d19dcb1f18..b815b849b4 100644 --- a/src/mlpack/core/tree/binary_space_tree/vantage_point_split_impl.hpp +++ b/src/mlpack/core/tree/binary_space_tree/vantage_point_split_impl.hpp @@ -89,7 +89,6 @@ SelectVantagePoint(const DistanceType& distance, const MatType& data, mu = arma::median(distances); } } - assert(bestSpread > 0); } } // namespace mlpack diff --git a/src/mlpack/core/tree/build_tree.hpp b/src/mlpack/core/tree/build_tree.hpp index d6ac3b63bd..dc2b2570db 100644 --- a/src/mlpack/core/tree/build_tree.hpp +++ b/src/mlpack/core/tree/build_tree.hpp @@ -21,8 +21,7 @@ template TreeType* BuildTree( MatType&& dataset, std::vector& oldFromNew, - const typename std::enable_if< - TreeTraits::RearrangesDataset>::type* = 0) + const std::enable_if_t::RearrangesDataset>* = 0) { return new TreeType(std::forward(dataset), oldFromNew); } @@ -32,8 +31,7 @@ template TreeType* BuildTree( MatType&& dataset, const std::vector& /* oldFromNew */, - const typename std::enable_if< - !TreeTraits::RearrangesDataset>::type* = 0) + const std::enable_if_t::RearrangesDataset>* = 0) { return new TreeType(std::forward(dataset)); } diff --git a/src/mlpack/core/tree/cellbound.hpp b/src/mlpack/core/tree/cellbound.hpp index 40b78ebe1f..21b31dbe9f 100644 --- a/src/mlpack/core/tree/cellbound.hpp +++ b/src/mlpack/core/tree/cellbound.hpp @@ -76,9 +76,9 @@ class CellBound public: //! Depending on the precision of the tree element type, we may need to use //! uint32_t or uint64_t. - typedef typename std::conditional::type AddressElemType; + uint64_t> AddressElemType; /** * Empty constructor; creates a bound of dimensionality 0. diff --git a/src/mlpack/core/tree/hollow_ball_bound_impl.hpp b/src/mlpack/core/tree/hollow_ball_bound_impl.hpp index 4d65a0aeec..41d3122234 100644 --- a/src/mlpack/core/tree/hollow_ball_bound_impl.hpp +++ b/src/mlpack/core/tree/hollow_ball_bound_impl.hpp @@ -316,8 +316,8 @@ RangeType HollowBallBound::RangeDistance( typename std::enable_if_t::value>* /* junk */) const { if (radii.Hi() < 0) - return Range(std::numeric_limits::max(), - std::numeric_limits::max()); + return RangeType(std::numeric_limits::max(), + std::numeric_limits::max()); else { RangeType range; @@ -461,7 +461,7 @@ void HollowBallBound::serialize( ar(CEREAL_NVP(radii)); ar(CEREAL_NVP(center)); ar(CEREAL_NVP(hollowCenter)); - ar(CEREAL_POINTER(distance)); + if (cereal::is_loading()) { // If we're loading, delete the local distance since we'll have a new one. @@ -470,6 +470,8 @@ void HollowBallBound::serialize( ownsDistance = true; } + + ar(CEREAL_POINTER(distance)); } } // namespace mlpack diff --git a/src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value.hpp b/src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value.hpp index 9ecb85ed86..62c1329b5f 100644 --- a/src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value.hpp +++ b/src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value.hpp @@ -30,9 +30,9 @@ class DiscreteHilbertValue public: //! Depending on the precision of the tree element type, we may need to use //! uint32_t or uint64_t. - typedef typename std::conditional::type HilbertElemType; + uint64_t> HilbertElemType; //! Default constructor. DiscreteHilbertValue(); diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp index 8978bcb9ff..6d382b822a 100644 --- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp +++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp @@ -53,7 +53,7 @@ template::value, + static_assert(std::is_same_v, "RectangleTree: DistanceType must be EuclideanDistance."); public: diff --git a/src/mlpack/core/util/ens_traits.hpp b/src/mlpack/core/util/ens_traits.hpp index 79c1635c3c..36faa4dcc8 100644 --- a/src/mlpack/core/util/ens_traits.hpp +++ b/src/mlpack/core/util/ens_traits.hpp @@ -45,7 +45,7 @@ struct IsEnsOptimizer OptimizerType, FunctionType, MatType, - std::is_class::value + std::is_class_v >::value; }; @@ -55,8 +55,7 @@ struct IsEnsOptimizerInternal { // If OptimizerType is a reference type, then forming the types below will // fail. So we need to strip the reference (and the const for good measure). - typedef typename std::remove_cv< - typename std::remove_reference::type>::type + typedef std::remove_cv_t> SafeOptimizerType; using OptimizeElemReturnForm = @@ -85,9 +84,8 @@ template struct IsEnsCallbackTypes { constexpr static bool value = - std::is_class::type - >::type>::value && IsEnsCallbackTypes::value; + std::is_class_v>> + && IsEnsCallbackTypes::value; }; template<> diff --git a/src/mlpack/core/util/first_element_is_arma.hpp b/src/mlpack/core/util/first_element_is_arma.hpp index d5828dcb5a..dd6d1fc11b 100644 --- a/src/mlpack/core/util/first_element_is_arma.hpp +++ b/src/mlpack/core/util/first_element_is_arma.hpp @@ -39,9 +39,7 @@ template struct FirstElementIsArma { static constexpr bool value = arma::is_arma_type< - typename std::remove_reference< - typename First::type - >::type>::value; + std::remove_reference_t::type>>::value; }; } // namespace mlpack diff --git a/src/mlpack/core/util/prefixedoutstream.hpp b/src/mlpack/core/util/prefixedoutstream.hpp index bca5639444..2947f24481 100644 --- a/src/mlpack/core/util/prefixedoutstream.hpp +++ b/src/mlpack/core/util/prefixedoutstream.hpp @@ -134,7 +134,7 @@ class PrefixedOutStream * @param val The The data to be output. */ template - typename std::enable_if::value>::type + std::enable_if_t::value> BaseLogic(const T& val); /** @@ -148,7 +148,7 @@ class PrefixedOutStream * @param val The The data to be output. */ template - typename std::enable_if::value>::type + std::enable_if_t::value> BaseLogic(const T& val); /** diff --git a/src/mlpack/core/util/prefixedoutstream_impl.hpp b/src/mlpack/core/util/prefixedoutstream_impl.hpp index 5f2aa48142..498fad50f3 100644 --- a/src/mlpack/core/util/prefixedoutstream_impl.hpp +++ b/src/mlpack/core/util/prefixedoutstream_impl.hpp @@ -146,7 +146,7 @@ inline PrefixedOutStream& PrefixedOutStream::operator<<( // For non-Armadillo types. template -typename std::enable_if::value>::type +std::enable_if_t::value> PrefixedOutStream::BaseLogic(const T& val) { // We will use this to track whether or not we need to terminate at the end of @@ -254,7 +254,7 @@ PrefixedOutStream::BaseLogic(const T& val) // For Armadillo types. template -typename std::enable_if::value>::type +std::enable_if_t::value> PrefixedOutStream::BaseLogic(const T& val) { // Extract printable object from the input. diff --git a/src/mlpack/core/util/sfinae_utility.hpp b/src/mlpack/core/util/sfinae_utility.hpp index 848fa515b7..e9cfc7eb54 100644 --- a/src/mlpack/core/util/sfinae_utility.hpp +++ b/src/mlpack/core/util/sfinae_utility.hpp @@ -155,8 +155,7 @@ struct NAME \ using no = char[2]; \ \ template \ - using EnableIfVoid = \ - typename std::enable_if::value, ResultType>::type; \ + using EnableIfVoid = std::enable_if_t, ResultType>; \ \ template \ static EnableIfVoid()(&C::METHOD)), yes&> chk(int); \ @@ -169,13 +168,13 @@ struct NAME \ template \ struct WithGreaterOrEqualNumberOfAdditionalArgs \ { \ - using type = typename std::conditional< \ + using type = std::conditional_t< \ WithNAdditionalArgs::value, \ std::true_type, \ - typename std::conditional< \ + std::conditional_t< \ N < MAXN, \ WithGreaterOrEqualNumberOfAdditionalArgs, \ - std::false_type>::type>::type; \ + std::false_type>>; \ static const bool value = type::value; \ }; \ \ @@ -196,20 +195,19 @@ struct NAME \ * function in the given class name. * This can also be used in conjunction with std::enable_if. */ -#define HAS_ANY_METHOD_FORM(FUNC, NAME) \ -template \ -struct NAME \ -{ \ - template \ - static typename \ - std::enable_if::value, \ - int>::type \ - f(int) { return 1;} \ - \ - template \ - static char f(char) { return 0; } \ - \ - static const bool value = sizeof(f(0)) != sizeof(char); \ +#define HAS_ANY_METHOD_FORM(FUNC, NAME) \ +template \ +struct NAME \ +{ \ + template \ + static \ + std::enable_if_t, int>\ + f(int) { return 1; } \ + \ + template \ + static char f(char) { return 0; } \ + \ + static const bool value = sizeof(f(0)) != sizeof(char); \ }; /* * A macro that can be used for passing arguments containing commas to other diff --git a/src/mlpack/core/util/size_checks.hpp b/src/mlpack/core/util/size_checks.hpp index 4f25af8021..6999ad31e3 100644 --- a/src/mlpack/core/util/size_checks.hpp +++ b/src/mlpack/core/util/size_checks.hpp @@ -39,8 +39,7 @@ inline void CheckSameSizes( const std::string& addInfo = "labels", const bool& isDataTranspose = false, const bool& isLabelTranspose = false, - const typename std::enable_if< - !std::is_integral::value>::type* = 0) + const std::enable_if_t>* = 0) { const size_t dataPoints = (isDataTranspose == true) ? data.n_rows : data.n_cols; @@ -67,7 +66,7 @@ inline void CheckSameSizes( const SizeType& size, const std::string& callerDescription, const std::string& addInfo = "labels", - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t>* = 0) { if (data.n_cols != size) { @@ -96,7 +95,7 @@ inline void CheckSameDimensionality( const DimType& dimension, const std::string& callerDescription, const std::string& addInfo = "dataset", - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t>* = 0) { if (data.n_rows != dimension.n_rows) { @@ -119,7 +118,7 @@ inline void CheckSameDimensionality( const DimType& dimension, const std::string& callerDescription, const std::string& addInfo = "dataset", - const typename std::enable_if::value>::type* = 0) + const std::enable_if_t>* = 0) { if (data.n_rows != dimension) { diff --git a/src/mlpack/core/util/using.hpp b/src/mlpack/core/util/using.hpp index 719a255cf6..de5f1c81a4 100644 --- a/src/mlpack/core/util/using.hpp +++ b/src/mlpack/core/util/using.hpp @@ -92,7 +92,7 @@ struct GetFillType // If the matrix type is a Bandicoot type, use Bandicoot fill objects instead. template< typename MatType, - typename = typename std::enable_if::value>::type*> + typename = std::enable_if_t::value>*> struct GetFillType { static constexpr const decltype(coot::fill::none)& none = coot::fill::none; diff --git a/src/mlpack/methods/adaboost/adaboost.hpp b/src/mlpack/methods/adaboost/adaboost.hpp index 6c5f19c9dd..a4d8b79966 100644 --- a/src/mlpack/methods/adaboost/adaboost.hpp +++ b/src/mlpack/methods/adaboost/adaboost.hpp @@ -130,9 +130,8 @@ class AdaBoost const WeakLearnerInType& other, const size_t maxIterations = 100, const ElemType tolerance = 1e-6, - const typename std::enable_if< - std::is_same::value - >::type* = 0); + const std::enable_if_t< + std::is_same_v>* = 0); //! Get the maximum number of weak learners allowed in the model. size_t MaxIterations() const { return maxIterations; } @@ -189,8 +188,8 @@ class AdaBoost const std::optional maxIterations = std::nullopt, const std::optional tolerance = std::nullopt, // Necessary to distinguish from other overloads. - const typename std::enable_if< - std::is_same::value>::type* = 0); + const std::enable_if_t< + std::is_same_v>* = 0); /** * Train AdaBoost on the given dataset, using the given parameters. The last diff --git a/src/mlpack/methods/adaboost/adaboost_impl.hpp b/src/mlpack/methods/adaboost/adaboost_impl.hpp index 006e4d8dde..7609ee7749 100644 --- a/src/mlpack/methods/adaboost/adaboost_impl.hpp +++ b/src/mlpack/methods/adaboost/adaboost_impl.hpp @@ -57,8 +57,8 @@ AdaBoost::AdaBoost( const WeakLearnerInType& other, const size_t maxIterations, const typename MatType::elem_type tol, - const typename std::enable_if< - std::is_same::value>::type*) : + const std::enable_if_t< + std::is_same_v>*) : maxIterations(maxIterations), tolerance(tol) { @@ -102,8 +102,8 @@ typename MatType::elem_type AdaBoost::Train( const WeakLearnerInType& other, const std::optional maxIterations, const std::optional tolerance, - const typename std::enable_if< - std::is_same::value>::type*) + const std::enable_if_t< + std::is_same_v>*) { if (maxIterations.has_value()) this->maxIterations = maxIterations.value(); @@ -229,7 +229,7 @@ void AdaBoost::serialize(Archive& ar, // In earlier versions, `alpha` was a vector of doubles---but it might not // be now. - if (std::is_same::value) + if (std::is_same_v) { ar(CEREAL_NVP(alpha)); // The easy case. } diff --git a/src/mlpack/methods/ann/convolution_rules/fft_convolution.hpp b/src/mlpack/methods/ann/convolution_rules/fft_convolution.hpp index a6e48ea4af..5e2dfa4772 100644 --- a/src/mlpack/methods/ann/convolution_rules/fft_convolution.hpp +++ b/src/mlpack/methods/ann/convolution_rules/fft_convolution.hpp @@ -48,8 +48,7 @@ class FFTConvolution * @param output Output data that contains the results of the convolution. */ template - static typename std::enable_if< - std::is_same::value, void>::type + static std::enable_if_t, void> Convolution(const MatType& input, const MatType& filter, MatType& output, @@ -83,8 +82,7 @@ class FFTConvolution * @param output Output data that contains the results of the convolution. */ template - static typename std::enable_if< - std::is_same::value, void>::type + static std::enable_if_t, void> Convolution(const MatType& input, const MatType& filter, MatType& output, diff --git a/src/mlpack/methods/ann/convolution_rules/naive_convolution.hpp b/src/mlpack/methods/ann/convolution_rules/naive_convolution.hpp index a472966794..a323c7b38f 100644 --- a/src/mlpack/methods/ann/convolution_rules/naive_convolution.hpp +++ b/src/mlpack/methods/ann/convolution_rules/naive_convolution.hpp @@ -49,8 +49,7 @@ class NaiveConvolution */ template - static typename std::enable_if< - std::is_same::value, void>::type + static std::enable_if_t, void> Convolution(const InMatType& input, const FilMatType& filter, OutMatType& output, @@ -110,8 +109,7 @@ class NaiveConvolution */ template - static typename std::enable_if< - std::is_same::value, void>::type + static std::enable_if_t, void> Convolution(const InMatType& input, const FilMatType& filter, OutMatType& output, diff --git a/src/mlpack/methods/ann/ffn.hpp b/src/mlpack/methods/ann/ffn.hpp index 7b895c0663..f4ca7ea933 100644 --- a/src/mlpack/methods/ann/ffn.hpp +++ b/src/mlpack/methods/ann/ffn.hpp @@ -486,9 +486,8 @@ class FFN * @param samples Number of datapoints in the dataset. */ template - typename std::enable_if< - ens::traits::HasMaxIterationsSignature::value, void - >::type + std::enable_if_t< + ens::traits::HasMaxIterationsSignature::value, void> WarnMessageMaxIterations(OptimizerType& optimizer, size_t samples) const; /** @@ -500,9 +499,8 @@ class FFN * @param samples Number of datapoints in the dataset. */ template - typename std::enable_if< - !ens::traits::HasMaxIterationsSignature::value, void - >::type + std::enable_if_t< + !ens::traits::HasMaxIterationsSignature::value, void> WarnMessageMaxIterations(OptimizerType& optimizer, size_t samples) const; //! Instantiated output layer used to evaluate the network. diff --git a/src/mlpack/methods/ann/ffn_impl.hpp b/src/mlpack/methods/ann/ffn_impl.hpp index 8e1bfdbb5f..e41b2f2db8 100644 --- a/src/mlpack/methods/ann/ffn_impl.hpp +++ b/src/mlpack/methods/ann/ffn_impl.hpp @@ -694,9 +694,8 @@ template template -typename std::enable_if< - ens::traits::HasMaxIterationsSignature::value, void ->::type +std::enable_if_t< + ens::traits::HasMaxIterationsSignature::value, void> FFN< OutputLayerType, InitializationRuleType, @@ -718,9 +717,8 @@ template template -typename std::enable_if< - !ens::traits::HasMaxIterationsSignature::value, void ->::type +std::enable_if_t< + !ens::traits::HasMaxIterationsSignature::value, void> FFN< OutputLayerType, InitializationRuleType, diff --git a/src/mlpack/methods/ann/not_adapted/brnn.hpp b/src/mlpack/methods/ann/not_adapted/brnn.hpp index d38089ed76..c90f59c196 100644 --- a/src/mlpack/methods/ann/not_adapted/brnn.hpp +++ b/src/mlpack/methods/ann/not_adapted/brnn.hpp @@ -89,9 +89,9 @@ class BRNN * @param samples Number of datapoints in the dataset. */ template - typename std::enable_if< + std::enable_if_t< HasMaxIterations - ::value, void>::type + ::value, void> WarnMessageMaxIterations(OptimizerType& optimizer, size_t samples) const; /** @@ -103,9 +103,9 @@ class BRNN * @param samples Number of datapoints in the dataset. */ template - typename std::enable_if< + std::enable_if_t< !HasMaxIterations - ::value, void>::type + ::value, void> WarnMessageMaxIterations(OptimizerType& optimizer, size_t samples) const; /** diff --git a/src/mlpack/methods/ann/not_adapted/brnn_impl.hpp b/src/mlpack/methods/ann/not_adapted/brnn_impl.hpp index 1d08a3cd7d..fdc7cb8e51 100644 --- a/src/mlpack/methods/ann/not_adapted/brnn_impl.hpp +++ b/src/mlpack/methods/ann/not_adapted/brnn_impl.hpp @@ -78,9 +78,9 @@ template template -typename std::enable_if< +std::enable_if_t< HasMaxIterations - ::value, void>::type + ::value, void> BRNN::WarnMessageMaxIterations (OptimizerType& optimizer, size_t samples) const @@ -102,9 +102,9 @@ template template -typename std::enable_if< +std::enable_if_t< !HasMaxIterations - ::value, void>::type + ::value, void> BRNN::WarnMessageMaxIterations (OptimizerType& /* optimizer */, size_t /* samples */) const @@ -201,7 +201,7 @@ void BRNN>::value) + if (std::is_same_v>) { results = zeros(outputSize * 2, predictors.n_cols, rho); } @@ -438,7 +438,7 @@ EvaluateWithGradient(const arma::mat& /* parameters */, } arma::cube results; - if (std::is_same>::value) + if (std::is_same_v>) { results = zeros(outputSize * 2, batchSize, rho); } diff --git a/src/mlpack/methods/ann/not_adapted/gan/gan.hpp b/src/mlpack/methods/ann/not_adapted/gan/gan.hpp index 4b32a605a1..0b2a43d0f8 100644 --- a/src/mlpack/methods/ann/not_adapted/gan/gan.hpp +++ b/src/mlpack/methods/ann/not_adapted/gan/gan.hpp @@ -134,8 +134,8 @@ class GAN * @param batchSize Variable to store the present number of inputs. */ template - typename std::enable_if::value || - std::is_same::value, double>::type + std::enable_if_t || + std::is_same_v, double> Evaluate(const arma::mat& parameters, const size_t i, const size_t batchSize); @@ -149,8 +149,7 @@ class GAN * @param batchSize Variable to store the present number of inputs. */ template - typename std::enable_if::value, - double>::type + std::enable_if_t, double> Evaluate(const arma::mat& parameters, const size_t i, const size_t batchSize); @@ -164,8 +163,7 @@ class GAN * @param batchSize Variable to store the present number of inputs. */ template - typename std::enable_if::value, - double>::type + std::enable_if_t, double> Evaluate(const arma::mat& parameters, const size_t i, const size_t batchSize); @@ -181,8 +179,8 @@ class GAN * @param batchSize Variable to store the present number of inputs. */ template - typename std::enable_if::value || - std::is_same::value, double>::type + std::enable_if_t || + std::is_same_v, double> EvaluateWithGradient(const arma::mat& parameters, const size_t i, GradType& gradient, @@ -199,8 +197,7 @@ class GAN * @param batchSize Variable to store the present number of inputs. */ template - typename std::enable_if::value, - double>::type + std::enable_if_t, double> EvaluateWithGradient(const arma::mat& parameters, const size_t i, GradType& gradient, @@ -217,8 +214,7 @@ class GAN * @param batchSize Variable to store the present number of inputs. */ template - typename std::enable_if::value, - double>::type + std::enable_if_t, double> EvaluateWithGradient(const arma::mat& parameters, const size_t i, GradType& gradient, @@ -235,8 +231,8 @@ class GAN * @param batchSize Variable to store the present number of inputs. */ template - typename std::enable_if::value || - std::is_same::value, void>::type + std::enable_if_t || + std::is_same_v, void> Gradient(const arma::mat& parameters, const size_t i, arma::mat& gradient, @@ -253,7 +249,7 @@ class GAN * @param batchSize Variable to store the present number of inputs. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> Gradient(const arma::mat& parameters, const size_t i, arma::mat& gradient, @@ -270,8 +266,7 @@ class GAN * @param batchSize Variable to store the present number of inputs. */ template - typename std::enable_if::value, - void>::type + std::enable_if_t, void> Gradient(const arma::mat& parameters, const size_t i, arma::mat& gradient, diff --git a/src/mlpack/methods/ann/not_adapted/gan/gan_impl.hpp b/src/mlpack/methods/ann/not_adapted/gan/gan_impl.hpp index 56459ddc57..1e29a4c573 100644 --- a/src/mlpack/methods/ann/not_adapted/gan/gan_impl.hpp +++ b/src/mlpack/methods/ann/not_adapted/gan/gan_impl.hpp @@ -233,8 +233,8 @@ template< typename PolicyType > template -typename std::enable_if::value || - std::is_same::value, double>::type +std::enable_if_t || + std::is_same_v, double> GAN::Evaluate( const arma::mat& /* parameters */, const size_t i, @@ -288,8 +288,8 @@ template< typename PolicyType > template -typename std::enable_if::value || - std::is_same::value, double>::type +std::enable_if_t || + std::is_same_v, double> GAN:: EvaluateWithGradient(const arma::mat& /* parameters */, const size_t i, @@ -391,8 +391,8 @@ template< typename PolicyType > template -typename std::enable_if::value || - std::is_same::value, void>::type +std::enable_if_t || + std::is_same_v, void> GAN:: Gradient(const arma::mat& parameters, const size_t i, diff --git a/src/mlpack/methods/ann/not_adapted/gan/wgan_impl.hpp b/src/mlpack/methods/ann/not_adapted/gan/wgan_impl.hpp index 56e02e7318..75fbfa1289 100644 --- a/src/mlpack/methods/ann/not_adapted/gan/wgan_impl.hpp +++ b/src/mlpack/methods/ann/not_adapted/gan/wgan_impl.hpp @@ -27,7 +27,7 @@ template< typename PolicyType > template -typename std::enable_if::value, double>::type +std::enable_if_t, double> GAN::Evaluate( const arma::mat& /* parameters */, const size_t i, @@ -82,7 +82,7 @@ template< typename PolicyType > template -typename std::enable_if::value, double>::type +std::enable_if_t, double> GAN:: EvaluateWithGradient(const arma::mat& /* parameters */, const size_t i, @@ -185,7 +185,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> GAN:: Gradient(const arma::mat& parameters, const size_t i, diff --git a/src/mlpack/methods/ann/not_adapted/gan/wgangp_impl.hpp b/src/mlpack/methods/ann/not_adapted/gan/wgangp_impl.hpp index f86fe5c43b..d983e48eb3 100644 --- a/src/mlpack/methods/ann/not_adapted/gan/wgangp_impl.hpp +++ b/src/mlpack/methods/ann/not_adapted/gan/wgangp_impl.hpp @@ -27,8 +27,7 @@ template< typename PolicyType > template -typename std::enable_if::value, - double>::type +std::enable_if_t, double> GAN::Evaluate( const arma::mat& /* parameters */, const size_t i, @@ -95,8 +94,7 @@ template< typename PolicyType > template -typename std::enable_if::value, - double>::type +std::enable_if_t, double> GAN:: EvaluateWithGradient(const arma::mat& /* parameters */, const size_t i, @@ -209,8 +207,7 @@ template< typename PolicyType > template -typename std::enable_if::value, - void>::type +std::enable_if_t, void> GAN:: Gradient(const arma::mat& parameters, const size_t i, diff --git a/src/mlpack/methods/ann/not_adapted/rbm/rbm.hpp b/src/mlpack/methods/ann/not_adapted/rbm/rbm.hpp index c7c34b9f08..b5afe73bf9 100644 --- a/src/mlpack/methods/ann/not_adapted/rbm/rbm.hpp +++ b/src/mlpack/methods/ann/not_adapted/rbm/rbm.hpp @@ -70,12 +70,12 @@ class RBM // Reset the network. template - typename std::enable_if::value, void>::type + std::enable_if_t, void> Reset(); // Reset the network. template - typename std::enable_if::value, void>::type + std::enable_if_t, void> Reset(); /** @@ -116,7 +116,7 @@ class RBM * @param input The visible neurons. */ template - typename std::enable_if::value, double>::type + std::enable_if_t, double> FreeEnergy(const arma::Mat& input); /** @@ -130,8 +130,7 @@ class RBM * @param input The visible layer neurons. */ template - typename std::enable_if::value, - double>::type + std::enable_if_t, double> FreeEnergy(const arma::Mat& input); /** @@ -141,7 +140,7 @@ class RBM * @param gradient Stores the gradient of the RBM network. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> Phase(const InputType& input, DataType& gradient); /** @@ -151,7 +150,7 @@ class RBM * @param gradient Stores the gradient of the RBM network. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> Phase(const InputType& input, DataType& gradient); /** @@ -162,7 +161,7 @@ class RBM * @param output The sampled hidden layer. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> SampleHidden(const arma::Mat& input, arma::Mat& output); /** @@ -176,7 +175,7 @@ class RBM * @param output Sampled slab neurons. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> SampleHidden(const arma::Mat& input, arma::Mat& output); /** @@ -187,7 +186,7 @@ class RBM * @param output The sampled visible layer. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> SampleVisible(arma::Mat& input, arma::Mat& output); /** @@ -201,7 +200,7 @@ class RBM * @param output The sampled visible layer. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> SampleVisible(arma::Mat& input, arma::Mat& output); /** @@ -211,7 +210,7 @@ class RBM * @param output Visible neuron activations. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> VisibleMean(InputType& input, DataType& output); /** @@ -223,7 +222,7 @@ class RBM * @param output Mean of the of the Normal distribution. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> VisibleMean(InputType& input, DataType& output); /** @@ -233,7 +232,7 @@ class RBM * @param output Hidden neuron activations. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> HiddenMean(const InputType& input, DataType& output); /** @@ -247,7 +246,7 @@ class RBM * @param output Consists of both the spike samples and slab samples. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> HiddenMean(const InputType& input, DataType& output); /** @@ -259,7 +258,7 @@ class RBM * @param spikeMean Indicates P(h|v). */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> SpikeMean(const InputType& visible, DataType& spikeMean); /** @@ -268,7 +267,7 @@ class RBM * @param spike Sampled binary spike variables. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> SampleSpike(InputType& spikeMean, DataType& spike); /** @@ -281,7 +280,7 @@ class RBM * @param slabMean The mean of the Normal distribution of slab neurons. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> SlabMean(const DataType& visible, DataType& spike, DataType& slabMean); /** @@ -295,7 +294,7 @@ class RBM * @param slab Sampled slab variable from the Normal distribution. */ template - typename std::enable_if::value, void>::type + std::enable_if_t, void> SampleSlab(InputType& slabMean, DataType& slab); /** diff --git a/src/mlpack/methods/ann/not_adapted/rbm/rbm_impl.hpp b/src/mlpack/methods/ann/not_adapted/rbm/rbm_impl.hpp index 2ec598d424..0ab6129f95 100644 --- a/src/mlpack/methods/ann/not_adapted/rbm/rbm_impl.hpp +++ b/src/mlpack/methods/ann/not_adapted/rbm/rbm_impl.hpp @@ -58,7 +58,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::Reset() { size_t shape = (visibleSize * hiddenSize) + visibleSize + hiddenSize; @@ -108,7 +108,7 @@ template< typename PolicyType > template -typename std::enable_if::value, double>::type +std::enable_if_t, double> RBM::FreeEnergy( const arma::Mat& input) { @@ -124,7 +124,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::Phase( const InputType& input, DataType& gradient) @@ -161,7 +161,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::SampleHidden( const arma::Mat& input, arma::Mat& output) @@ -180,7 +180,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::SampleVisible( arma::Mat& input, arma::Mat& output) @@ -199,7 +199,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::VisibleMean( InputType& input, DataType& output) @@ -215,7 +215,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::HiddenMean( const InputType& input, DataType& output) diff --git a/src/mlpack/methods/ann/not_adapted/rbm/spike_slab_rbm_impl.hpp b/src/mlpack/methods/ann/not_adapted/rbm/spike_slab_rbm_impl.hpp index 3a8da8c70e..633ddf9c53 100644 --- a/src/mlpack/methods/ann/not_adapted/rbm/spike_slab_rbm_impl.hpp +++ b/src/mlpack/methods/ann/not_adapted/rbm/spike_slab_rbm_impl.hpp @@ -25,7 +25,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::Reset() { size_t shape = (visibleSize * hiddenSize * poolSize) + visibleSize + @@ -65,7 +65,7 @@ template< typename PolicyType > template -typename std::enable_if::value, double>::type +std::enable_if_t, double> RBM::FreeEnergy( const arma::Mat& input) { @@ -90,7 +90,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::Phase( const InputType& input, DataType& gradient) @@ -123,7 +123,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::SampleHidden( const arma::Mat& input, arma::Mat& output) @@ -146,7 +146,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::SampleVisible( arma::Mat& input, arma::Mat& output) @@ -184,7 +184,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::VisibleMean( InputType& input, DataType& output) @@ -209,7 +209,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::HiddenMean( const InputType& input, DataType& output) @@ -231,7 +231,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::SpikeMean( const InputType& visible, DataType& spikeMean) @@ -250,7 +250,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::SampleSpike( InputType& spikeMean, DataType& spike) @@ -267,7 +267,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::SlabMean( const DataType& visible, DataType& spike, @@ -286,7 +286,7 @@ template< typename PolicyType > template -typename std::enable_if::value, void>::type +std::enable_if_t, void> RBM::SampleSlab( InputType& slabMean, DataType& slab) diff --git a/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression.hpp b/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression.hpp index f59dea34b1..06459fbd1f 100644 --- a/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression.hpp +++ b/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression.hpp @@ -139,9 +139,8 @@ class BayesianLinearRegression */ template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> BayesianLinearRegression(const MatType& data, const ResponsesType& responses, const bool centerData = true, @@ -175,9 +174,8 @@ class BayesianLinearRegression template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const std::optional centerData = std::nullopt, @@ -187,9 +185,8 @@ class BayesianLinearRegression template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool centerData, @@ -231,9 +228,8 @@ class BayesianLinearRegression */ template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> void Predict(const MatType& points, ResponsesType& predictions) const; @@ -249,9 +245,8 @@ class BayesianLinearRegression */ template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> void Predict(const MatType& points, ResponsesType& predictions, ResponsesType& std) const; @@ -266,9 +261,8 @@ class BayesianLinearRegression **/ template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType RMSE(const MatType& data, const ResponsesType& responses) const; diff --git a/src/mlpack/methods/decision_tree/decision_tree.hpp b/src/mlpack/methods/decision_tree/decision_tree.hpp index 24409fa2db..5ed4cbd9bd 100644 --- a/src/mlpack/methods/decision_tree/decision_tree.hpp +++ b/src/mlpack/methods/decision_tree/decision_tree.hpp @@ -130,7 +130,7 @@ class DecisionTree : const size_t maximumDepth = 0, DimensionSelectionType dimensionSelector = DimensionSelectionType(), const std::enable_if_t::type>::value>* = 0); + std::remove_reference_t>::value>* = 0); /** * Construct the decision tree on the given data and labels with weights, @@ -161,7 +161,7 @@ class DecisionTree : const size_t maximumDepth = 0, DimensionSelectionType dimensionSelector = DimensionSelectionType(), const std::enable_if_t::type>::value>* = 0); + std::remove_reference_t>::value>* = 0); /** * Using the hyperparameters of another decision tree, train on the given data @@ -193,7 +193,7 @@ class DecisionTree : const size_t minimumLeafSize = 10, const double minimumGainSplit = 1e-7, const std::enable_if_t::type>::value>* = 0); + std::remove_reference_t>::value>* = 0); /** * Take ownership of another decision tree and train on the given data and @@ -225,7 +225,7 @@ class DecisionTree : const size_t maximumDepth = 0, DimensionSelectionType dimensionSelector = DimensionSelectionType(), const std::enable_if_t::type>::value>* = 0); + std::remove_reference_t>::value>* = 0); /** * Construct a decision tree without training it. It will be a leaf node with @@ -359,8 +359,8 @@ class DecisionTree : const size_t maximumDepth = 0, DimensionSelectionType dimensionSelector = DimensionSelectionType(), - const std::enable_if_t::type>::value>* = 0); + const std::enable_if_t>::value>* = 0); /** * Train the decision tree on the given weighted data, assuming that all @@ -391,8 +391,8 @@ class DecisionTree : const size_t maximumDepth = 0, DimensionSelectionType dimensionSelector = DimensionSelectionType(), - const std::enable_if_t::type>::value>* = 0); + const std::enable_if_t>::value>* = 0); /** * Classify the given point, using the entire tree. The predicted label is diff --git a/src/mlpack/methods/decision_tree/decision_tree_impl.hpp b/src/mlpack/methods/decision_tree/decision_tree_impl.hpp index 799aebf406..c677e34c47 100644 --- a/src/mlpack/methods/decision_tree/decision_tree_impl.hpp +++ b/src/mlpack/methods/decision_tree/decision_tree_impl.hpp @@ -37,8 +37,8 @@ DecisionTree::type; - using TrueLabelsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueLabelsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -74,8 +74,8 @@ DecisionTree::type; - using TrueLabelsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueLabelsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -112,11 +112,11 @@ DecisionTree::type>::value>*) + std::remove_reference_t>::value>*) { - using TrueMatType = typename std::decay::type; - using TrueLabelsType = typename std::decay::type; - using TrueWeightsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueLabelsType = std::decay_t; + using TrueWeightsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -153,11 +153,11 @@ DecisionTree::type>::value>*) + std::remove_reference_t>::value>*) { - using TrueMatType = typename std::decay::type; - using TrueLabelsType = typename std::decay::type; - using TrueWeightsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueLabelsType = std::decay_t; + using TrueWeightsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -193,13 +193,13 @@ DecisionTree::type>::value>*): + std::remove_reference_t>::value>*): NumericAuxiliarySplitInfo(other), CategoricalAuxiliarySplitInfo(other) { - using TrueMatType = typename std::decay::type; - using TrueLabelsType = typename std::decay::type; - using TrueWeightsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueLabelsType = std::decay_t; + using TrueWeightsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -233,14 +233,13 @@ DecisionTree::type>::value>*): + std::remove_reference_t>::value>*): NumericAuxiliarySplitInfo(other), CategoricalAuxiliarySplitInfo(other) // other info does need to copy { - using TrueMatType = typename std::decay::type; - using TrueLabelsType = typename std::decay::type; - using TrueWeightsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueLabelsType = std::decay_t; + using TrueWeightsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -458,8 +457,8 @@ double DecisionTree::type; - using TrueLabelsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueLabelsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -498,8 +497,8 @@ double DecisionTree::type; - using TrueLabelsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueLabelsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -537,16 +536,14 @@ double DecisionTree::type>::value>*) + arma::is_arma_type>::value>*) { // Sanity check on data. util::CheckSameSizes(data, labels, "DecisionTree::Train()"); - using TrueMatType = typename std::decay::type; - using TrueLabelsType = typename std::decay::type; - using TrueWeightsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueLabelsType = std::decay_t; + using TrueWeightsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -583,16 +580,14 @@ double DecisionTree::type>::value>*) + arma::is_arma_type>::value>*) { // Sanity check on data. util::CheckSameSizes(data, labels, "DecisionTree::Train()"); - using TrueMatType = typename std::decay::type; - using TrueLabelsType = typename std::decay::type; - using TrueWeightsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueLabelsType = std::decay_t; + using TrueWeightsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); diff --git a/src/mlpack/methods/decision_tree/decision_tree_regressor.hpp b/src/mlpack/methods/decision_tree/decision_tree_regressor.hpp index f5441b509d..b0f4a61241 100644 --- a/src/mlpack/methods/decision_tree/decision_tree_regressor.hpp +++ b/src/mlpack/methods/decision_tree/decision_tree_regressor.hpp @@ -129,7 +129,7 @@ class DecisionTreeRegressor : const size_t maximumDepth = 0, DimensionSelectionType dimensionSelector = DimensionSelectionType(), const std::enable_if_t::type>::value>* = 0); + std::remove_reference_t>::value>* = 0); /** * Construct the decision tree on the given data and responses with weights, @@ -158,7 +158,7 @@ class DecisionTreeRegressor : const size_t maximumDepth = 0, DimensionSelectionType dimensionSelector = DimensionSelectionType(), const std::enable_if_t::type>::value>* = 0); + std::remove_reference_t>::value>* = 0); /** * Take ownership of another decision tree and train on the given data and @@ -188,7 +188,7 @@ class DecisionTreeRegressor : const size_t minimumLeafSize = 10, const double minimumGainSplit = 1e-7, const std::enable_if_t::type>::value>* = 0); + std::remove_reference_t>::value>* = 0); /** * Take ownership of another decision tree and train on the given data and @@ -218,7 +218,7 @@ class DecisionTreeRegressor : const size_t maximumDepth = 0, DimensionSelectionType dimensionSelector = DimensionSelectionType(), const std::enable_if_t::type>::value>* = 0); + std::remove_reference_t>::value>* = 0); /** * Copy another tree. This may use a lot of memory---be sure that it's what @@ -347,8 +347,8 @@ class DecisionTreeRegressor : DimensionSelectionType dimensionSelector = DimensionSelectionType(), FitnessFunction fitnessFunction = FitnessFunction(), - const std::enable_if_t::type>::value>* = 0); + const std::enable_if_t>::value>* = 0); /** * Train the decision tree on the given weighted data, assuming that all @@ -380,8 +380,8 @@ class DecisionTreeRegressor : DimensionSelectionType dimensionSelector = DimensionSelectionType(), FitnessFunction fitnessFunction = FitnessFunction(), - const std::enable_if_t::type>::value>* = 0); + const std::enable_if_t>::value>* = 0); /** * Make prediction for the given point, using the entire tree. The predicted diff --git a/src/mlpack/methods/decision_tree/decision_tree_regressor_impl.hpp b/src/mlpack/methods/decision_tree/decision_tree_regressor_impl.hpp index 05875a75f1..73b226c89b 100644 --- a/src/mlpack/methods/decision_tree/decision_tree_regressor_impl.hpp +++ b/src/mlpack/methods/decision_tree/decision_tree_regressor_impl.hpp @@ -52,8 +52,8 @@ DecisionTreeRegressor::type; - using TrueResponsesType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueResponsesType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -88,8 +88,8 @@ DecisionTreeRegressor::type; - using TrueResponsesType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueResponsesType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -125,12 +125,12 @@ DecisionTreeRegressor::type>::value>*) + std::remove_reference_t>::value>*) : splitInfo() { - using TrueMatType = typename std::decay::type; - using TrueResponsesType = typename std::decay::type; - using TrueWeightsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueResponsesType = std::decay_t; + using TrueWeightsType = std::decay_t; TrueMatType tmpData(std::move(data)); TrueResponsesType tmpResponses(std::move(responses)); @@ -165,13 +165,12 @@ DecisionTreeRegressor::type>::value>*) : splitInfo() + arma::is_arma_type>::value>*) : + splitInfo() { - using TrueMatType = typename std::decay::type; - using TrueResponsesType = typename std::decay::type; - using TrueWeightsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueResponsesType = std::decay_t; + using TrueWeightsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -206,14 +205,14 @@ DecisionTreeRegressor::type>::value>*): - splitInfo(std::move(other.splitInfo)), - NumericAuxiliarySplitInfo(other), - CategoricalAuxiliarySplitInfo(other) + std::remove_reference_t>::value>*) : + splitInfo(std::move(other.splitInfo)), + NumericAuxiliarySplitInfo(other), + CategoricalAuxiliarySplitInfo(other) { - using TrueMatType = typename std::decay::type; - using TrueResponsesType = typename std::decay::type; - using TrueWeightsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueResponsesType = std::decay_t; + using TrueWeightsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -246,15 +245,14 @@ DecisionTreeRegressor::type>::value>*): - splitInfo(std::move(other.splitInfo)), - NumericAuxiliarySplitInfo(other), - CategoricalAuxiliarySplitInfo(other) // other info does need to copy + std::remove_reference_t>::value>*) : + splitInfo(std::move(other.splitInfo)), + NumericAuxiliarySplitInfo(other), + CategoricalAuxiliarySplitInfo(other) // other info does need to copy { - using TrueMatType = typename std::decay::type; - using TrueResponsesType = typename std::decay::type; - using TrueWeightsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueResponsesType = std::decay_t; + using TrueWeightsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -442,8 +440,8 @@ double DecisionTreeRegressor::type; - using TrueResponsesType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueResponsesType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -482,8 +480,8 @@ double DecisionTreeRegressor::type; - using TrueResponsesType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueResponsesType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -521,16 +519,14 @@ double DecisionTreeRegressor::type>::value>*) + arma::is_arma_type>::value>*) { // Sanity check on data. util::CheckSameSizes(data, responses, "DecisionTreeRegressor::Train()"); - using TrueMatType = typename std::decay::type; - using TrueResponsesType = typename std::decay::type; - using TrueWeightsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueResponsesType = std::decay_t; + using TrueWeightsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); @@ -567,16 +563,14 @@ double DecisionTreeRegressor::type>::value>*) + arma::is_arma_type>::value>*) { // Sanity check on data. util::CheckSameSizes(data, responses, "DecisionTreeRegressor::Train()"); - using TrueMatType = typename std::decay::type; - using TrueResponsesType = typename std::decay::type; - using TrueWeightsType = typename std::decay::type; + using TrueMatType = std::decay_t; + using TrueResponsesType = std::decay_t; + using TrueWeightsType = std::decay_t; // Copy or move data. TrueMatType tmpData(std::move(data)); diff --git a/src/mlpack/methods/decision_tree/splits/best_binary_categorical_split_impl.hpp b/src/mlpack/methods/decision_tree/splits/best_binary_categorical_split_impl.hpp index d5cd9ccd58..1e078c5600 100644 --- a/src/mlpack/methods/decision_tree/splits/best_binary_categorical_split_impl.hpp +++ b/src/mlpack/methods/decision_tree/splits/best_binary_categorical_split_impl.hpp @@ -157,7 +157,7 @@ double BestBinaryCategoricalSplit::SplitIfBetter( AuxiliarySplitInfo& aux, FitnessFunction& fitnessFunction) { - static_assert(std::is_same::value, + static_assert(std::is_same_v, "BestBinaryCategoricalSplit: regression FitnessFunction must be " "MSEGain."); const size_t n = data.n_elem; diff --git a/src/mlpack/methods/decision_tree/splits/best_binary_numeric_split.hpp b/src/mlpack/methods/decision_tree/splits/best_binary_numeric_split.hpp index bc1adac8f9..3857ff9cd5 100644 --- a/src/mlpack/methods/decision_tree/splits/best_binary_numeric_split.hpp +++ b/src/mlpack/methods/decision_tree/splits/best_binary_numeric_split.hpp @@ -108,9 +108,9 @@ class BestBinaryNumericSplit */ template - static typename std::enable_if< + static std::enable_if_t< !HasOptimizedBinarySplitForms::value, - double>::type + double> SplitIfBetter( const double bestGain, const VecType& data, @@ -145,9 +145,9 @@ class BestBinaryNumericSplit */ template - static typename std::enable_if< + static std::enable_if_t< HasOptimizedBinarySplitForms::value, - double>::type + double> SplitIfBetter( const double bestGain, const VecType& data, diff --git a/src/mlpack/methods/decision_tree/splits/best_binary_numeric_split_impl.hpp b/src/mlpack/methods/decision_tree/splits/best_binary_numeric_split_impl.hpp index a5717e2347..4687506a16 100644 --- a/src/mlpack/methods/decision_tree/splits/best_binary_numeric_split_impl.hpp +++ b/src/mlpack/methods/decision_tree/splits/best_binary_numeric_split_impl.hpp @@ -207,9 +207,9 @@ double BestBinaryNumericSplit::SplitIfBetter( template template -typename std::enable_if< +std::enable_if_t< !HasOptimizedBinarySplitForms::value, - double>::type + double> BestBinaryNumericSplit::SplitIfBetter( const double bestGain, const VecType& data, @@ -363,9 +363,9 @@ BestBinaryNumericSplit::SplitIfBetter( template template -typename std::enable_if< +std::enable_if_t< HasOptimizedBinarySplitForms::value, - double>::type + double> BestBinaryNumericSplit::SplitIfBetter( const double bestGain, const VecType& data, diff --git a/src/mlpack/methods/det/dtree_impl.hpp b/src/mlpack/methods/det/dtree_impl.hpp index fe1100b178..78239a60de 100644 --- a/src/mlpack/methods/det/dtree_impl.hpp +++ b/src/mlpack/methods/det/dtree_impl.hpp @@ -29,8 +29,7 @@ void ExtractSplits(std::vector>& splitVec, const size_t end, const size_t minLeafSize) { - static_assert( - std::is_same::value == true, + static_assert(std::is_same_v, "The ElemType does not correspond to the matrix's element type."); typedef std::pair SplitItem; diff --git a/src/mlpack/methods/gmm/em_fit_impl.hpp b/src/mlpack/methods/gmm/em_fit_impl.hpp index 19fc220b7d..26af885206 100644 --- a/src/mlpack/methods/gmm/em_fit_impl.hpp +++ b/src/mlpack/methods/gmm/em_fit_impl.hpp @@ -44,7 +44,7 @@ Estimate(const arma::mat& observations, arma::vec& weights, const bool useInitialModel) { - if (std::is_same>::value) + if (std::is_same_v>) { #ifdef _WIN32 Log::Warn << "Cannot use arma::gmm_diag on Visual Studio due to OpenMP" @@ -55,8 +55,8 @@ Estimate(const arma::mat& observations, return; #endif } - else if (std::is_same::value - && std::is_same>::value) + else if (std::is_same_v + && std::is_same_v>) { // EMFit::Estimate() using DiagonalConstraint with GaussianDistribution // makes use of slower implementation. @@ -129,7 +129,7 @@ Estimate(const arma::mat& observations, // If the distribution is DiagonalGaussianDistribution, calculate the // covariance only with diagonal components. - if (std::is_same>::value) + if (std::is_same_v>) { arma::vec covariance = sum((tmp % tmp) % (ones(observations.n_rows) * @@ -240,7 +240,7 @@ Estimate(const arma::mat& observations, // If the distribution is DiagonalGaussianDistribution, calculate the // covariance only with diagonal components. - if (std::is_same>::value) + if (std::is_same_v>) { arma::vec cov = sum((tmp % tmp) % (ones(observations.n_rows) * @@ -292,14 +292,14 @@ InitialClustering(const arma::mat& observations, // Check if the type of Distribution is DiagonalGaussianDistribution. If so, // we can get faster performance by using diagonal elements when calculating // the covariance. - const bool isDiagGaussDist = std::is_same>::value; + const bool isDiagGaussDist = std::is_same_v>; std::vector means(dists.size()); // Conditional covariance instantiation. - std::vector::type> covs(dists.size()); + std::vector> + covs(dists.size()); // Now calculate the means, covariances, and weights. weights.zeros(); @@ -437,7 +437,7 @@ ArmadilloGMMWrapper(const arma::mat& observations, // Armadillo's implementation. If mlpack ever changes k-means defaults to use // something that is reliably quicker than the Lloyd iteration k-means update, // then this code maybe should be revisited. - if (!std::is_same>::value || useInitialModel) + if (!std::is_same_v> || useInitialModel) { // Use clusterer to get initial values. if (!useInitialModel) diff --git a/src/mlpack/methods/gmm/positive_definite_constraint.hpp b/src/mlpack/methods/gmm/positive_definite_constraint.hpp index 23742975bb..29d1e12f67 100644 --- a/src/mlpack/methods/gmm/positive_definite_constraint.hpp +++ b/src/mlpack/methods/gmm/positive_definite_constraint.hpp @@ -35,8 +35,7 @@ class PositiveDefiniteConstraint template static void ApplyConstraint( MatType& covariance, - const typename std::enable_if::value>::type* - /* junk */ = 0) + const std::enable_if_t::value>* /* junk */ = 0) { typedef typename MatType::elem_type ElemType; typedef typename GetColType::type VecType; @@ -82,8 +81,7 @@ class PositiveDefiniteConstraint template static void ApplyConstraint( VecType& diagCovariance, - const typename std::enable_if::value>::type* - /* junk */ = 0) + const std::enable_if_t::value>* /* junk */ = 0) { typedef typename VecType::elem_type ElemType; diff --git a/src/mlpack/methods/kde/kde_impl.hpp b/src/mlpack/methods/kde/kde_impl.hpp index 4bf4b939c0..6e5fe10fed 100644 --- a/src/mlpack/methods/kde/kde_impl.hpp +++ b/src/mlpack/methods/kde/kde_impl.hpp @@ -498,7 +498,7 @@ Evaluate(Tree* queryTree, } // Clean accumulated alpha if Monte Carlo estimations are available. - if (monteCarlo && std::is_same::value) + if (monteCarlo && std::is_same_v) { KDECleanRules cleanRules; SingleTreeTraversalType> cleanTraverser(cleanRules); @@ -562,7 +562,7 @@ Evaluate(arma::vec& estimations) estimations.fill(arma::fill::zeros); // Clean accumulated alpha if Monte Carlo estimations are available. - if (monteCarlo && std::is_same::value) + if (monteCarlo && std::is_same_v) { KDECleanRules cleanRules; SingleTreeTraversalType> cleanTraverser(cleanRules); diff --git a/src/mlpack/methods/kde/kde_model.hpp b/src/mlpack/methods/kde/kde_model.hpp index 835c883a94..e520405f14 100644 --- a/src/mlpack/methods/kde/kde_model.hpp +++ b/src/mlpack/methods/kde/kde_model.hpp @@ -43,9 +43,9 @@ class KernelNormalizer KernelType& /* kernel */, const size_t /* dimension */, arma::vec& /* estimations */, - const typename std::enable_if< - !HasNormalizer::value>:: - type* = 0) + const std::enable_if_t< + !HasNormalizer::value>* + = 0) { return; } //! Normalize kernels that have normalizer. @@ -54,9 +54,9 @@ class KernelNormalizer KernelType& kernel, const size_t dimension, arma::vec& estimations, - const typename std::enable_if< - HasNormalizer::value>:: - type* = 0) + const std::enable_if_t< + HasNormalizer::value>* + = 0) { estimations /= kernel.Normalizer(dimension); } diff --git a/src/mlpack/methods/kde/kde_rules.hpp b/src/mlpack/methods/kde/kde_rules.hpp index 671abbc478..1a77894c40 100644 --- a/src/mlpack/methods/kde/kde_rules.hpp +++ b/src/mlpack/methods/kde/kde_rules.hpp @@ -159,7 +159,7 @@ class KDERules //! Whether the kernel used for the rule is the Gaussian Kernel. constexpr static bool kernelIsGaussian = - std::is_same::value; + std::is_same_v; //! Absolute error tolerance available for each reference point. const double absErrorTol; diff --git a/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp b/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp index 8181b49512..f5c7df5a58 100644 --- a/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp +++ b/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp @@ -27,8 +27,7 @@ template TreeType* BuildForcedLeafSizeTree( MatType&& dataset, std::vector& oldFromNew, - const typename std::enable_if< - TreeTraits::RearrangesDataset>::type* = 0) + const std::enable_if_t::RearrangesDataset>* = 0) { // This is a hack. I know this will be BinarySpaceTree, so force a leaf size // of one. @@ -40,8 +39,7 @@ template TreeType* BuildForcedLeafSizeTree( MatType&& dataset, const std::vector& /* oldFromNew */, - const typename std::enable_if< - !TreeTraits::RearrangesDataset>::type* = 0) + const std::enable_if_t::RearrangesDataset>* = 0) { return new TreeType(std::forward(dataset)); } diff --git a/src/mlpack/methods/lars/lars.hpp b/src/mlpack/methods/lars/lars.hpp index 32bf5c6b7e..0700b686f5 100644 --- a/src/mlpack/methods/lars/lars.hpp +++ b/src/mlpack/methods/lars/lars.hpp @@ -165,9 +165,8 @@ class LARS */ template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> LARS(const MatType& data, const ResponsesType& responses, bool colMajor = true, @@ -204,9 +203,8 @@ class LARS */ template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> LARS(const MatType& data, const ResponsesType& responses, const bool colMajor, @@ -296,12 +294,10 @@ class LARS template::value - >::type, - typename = typename std::enable_if< - !std::is_same::value - >::type> + typename = std::enable_if_t< + std::is_same_v>, + typename = std::enable_if_t< + !std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor = true); @@ -309,9 +305,8 @@ class LARS template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor, @@ -320,9 +315,8 @@ class LARS template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor, @@ -332,9 +326,8 @@ class LARS template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor, @@ -345,9 +338,8 @@ class LARS template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor, @@ -359,9 +351,8 @@ class LARS template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor, @@ -374,9 +365,8 @@ class LARS template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor, @@ -407,9 +397,8 @@ class LARS template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor, @@ -419,9 +408,8 @@ class LARS template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor, @@ -432,9 +420,8 @@ class LARS template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor, @@ -446,9 +433,8 @@ class LARS template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor, @@ -461,9 +447,8 @@ class LARS template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor, @@ -477,9 +462,8 @@ class LARS template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& data, const ResponsesType& responses, const bool colMajor, diff --git a/src/mlpack/methods/linear_regression/linear_regression.hpp b/src/mlpack/methods/linear_regression/linear_regression.hpp index 71d28e1933..d36c855d7d 100644 --- a/src/mlpack/methods/linear_regression/linear_regression.hpp +++ b/src/mlpack/methods/linear_regression/linear_regression.hpp @@ -43,9 +43,8 @@ class LinearRegression */ template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> LinearRegression(const MatType& predictors, const ResponsesType& responses, const double lambda = 0, @@ -63,12 +62,10 @@ class LinearRegression template::value - >::type, - typename = typename std::enable_if< - std::is_same::value - >::type> + typename = std::enable_if_t< + std::is_same_v>, + typename = std::enable_if_t< + std::is_same_v>> LinearRegression(const MatType& predictors, const ResponsesType& responses, const WeightsType& weights, @@ -103,8 +100,7 @@ class LinearRegression double Train(const arma::mat& predictors, const arma::rowvec& responses, const T intercept, - const typename std::enable_if::value - >::type* = 0); + const std::enable_if_t>* = 0); /** * Train the LinearRegression model on the given data and instance weights. @@ -129,8 +125,7 @@ class LinearRegression const arma::rowvec& responses, const arma::rowvec& weights, const T intercept, - const typename std::enable_if::value - >::type* = 0); + const std::enable_if_t>* = 0); /** * Train the LinearRegression model. This is a dummy overload so that @@ -157,9 +152,8 @@ class LinearRegression template::value - >::type> + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& predictors, const ResponsesType& responses, const std::optional lambda = std::nullopt, @@ -192,12 +186,10 @@ class LinearRegression template::value - >::type, - typename = typename std::enable_if< - std::is_same::value - >::type> + typename = std::enable_if_t< + std::is_same_v>, + typename = std::enable_if_t< + std::is_same_v>> ElemType Train(const MatType& predictors, const ResponsesType& responses, const WeightsType& weights, diff --git a/src/mlpack/methods/linear_regression/linear_regression_impl.hpp b/src/mlpack/methods/linear_regression/linear_regression_impl.hpp index 1b3569d1e8..7676370ef3 100644 --- a/src/mlpack/methods/linear_regression/linear_regression_impl.hpp +++ b/src/mlpack/methods/linear_regression/linear_regression_impl.hpp @@ -51,7 +51,7 @@ inline double LinearRegression::Train( const arma::mat& predictors, const arma::rowvec& responses, const T intercept, - const typename std::enable_if::value>::type*) + const std::enable_if_t>*) { return Train(predictors, responses, arma::rowvec(), this->lambda, intercept); } @@ -63,7 +63,7 @@ inline double LinearRegression::Train( const arma::rowvec& responses, const arma::rowvec& weights, const T intercept, - const typename std::enable_if::value>::type*) + const std::enable_if_t>*) { return Train(predictors, responses, weights, this->lambda, intercept); } diff --git a/src/mlpack/methods/linear_svm/linear_svm.hpp b/src/mlpack/methods/linear_svm/linear_svm.hpp index 61fb7875f6..dd680da97b 100644 --- a/src/mlpack/methods/linear_svm/linear_svm.hpp +++ b/src/mlpack/methods/linear_svm/linear_svm.hpp @@ -135,14 +135,14 @@ class LinearSVM */ template, ModelMatType - >::value>::type, - typename = typename std::enable_if::value>, + typename = std::enable_if_t::value>::type> + >::value>> [[deprecated("Will be removed in mlpack 5.0.0, use other constructors")]] LinearSVM(const arma::mat& data, const arma::Row& labels, @@ -173,11 +173,11 @@ class LinearSVM * @param optimizer Desired optimizer. */ template, ModelMatType - >::value>::type> + >::value>> [[deprecated("Will be removed in mlpack 5.0.0, use other constructors")]] LinearSVM(const arma::mat& data, const arma::Row& labels, @@ -203,9 +203,9 @@ class LinearSVM */ template::value>::type> + >::value>> LinearSVM(const MatType& data, const arma::Row& labels, const size_t numClasses, @@ -232,9 +232,9 @@ class LinearSVM template::value>::type> + >::value>> LinearSVM(const MatType& data, const arma::Row& labels, const size_t numClasses, @@ -259,9 +259,9 @@ class LinearSVM */ template::value>::type> + >::value>> ElemType Train(const MatType& data, const arma::Row& labels, const size_t numClasses, @@ -269,9 +269,9 @@ class LinearSVM template::value>::type> + >::value>> ElemType Train(const MatType& data, const arma::Row& labels, const size_t numClasses, @@ -299,14 +299,14 @@ class LinearSVM template, ModelMatType - >::value>::type, - typename = typename std::enable_if::value>, + typename = std::enable_if_t::value>::type> + >::value>> ElemType Train(const MatType& data, const arma::Row& labels, const size_t numClasses, @@ -316,14 +316,14 @@ class LinearSVM template, ModelMatType - >::value>::type, - typename = typename std::enable_if::value>, + typename = std::enable_if_t::value>::type> + >::value>> ElemType Train(const MatType& data, const arma::Row& labels, const size_t numClasses, diff --git a/src/mlpack/methods/lmnn/lmnn.hpp b/src/mlpack/methods/lmnn/lmnn.hpp index 8dadc5b31e..e2ba1edebc 100644 --- a/src/mlpack/methods/lmnn/lmnn.hpp +++ b/src/mlpack/methods/lmnn/lmnn.hpp @@ -97,12 +97,11 @@ class LMNN * See https://www.ensmallen.org/docs.html#callback-documentation. */ template::value>::type, - typename = typename std::enable_if< - !FirstElementIsArma::value - >::type> + >::value>, + typename = std::enable_if_t< + !FirstElementIsArma::value>> [[deprecated("Will be removed in mlpack 5.0.0. Use the version that takes a " "dataset as a parameter.")]] void LearnDistance(arma::mat& outputMatrix, CallbackTypes&&... callbacks); @@ -122,14 +121,14 @@ class LMNN template::type, LMNNFunction, MatType - >::value>::type, - typename = typename std::enable_if::value>, + typename = std::enable_if_t::value>::type> + >::value>> void LearnDistance(const MatType& dataset, const LabelsType& labels, MatType& outputMatrix, @@ -152,11 +151,11 @@ class LMNN typename LabelsType, typename OptimizerType, typename... CallbackTypes, - typename = typename std::enable_if, MatType - >::value>::type> + >::value>> void LearnDistance(const MatType& dataset, const LabelsType& labels, MatType& outputMatrix, diff --git a/src/mlpack/methods/local_coordinate_coding/lcc_impl.hpp b/src/mlpack/methods/local_coordinate_coding/lcc_impl.hpp index 2894d015f6..f7d9c7090c 100644 --- a/src/mlpack/methods/local_coordinate_coding/lcc_impl.hpp +++ b/src/mlpack/methods/local_coordinate_coding/lcc_impl.hpp @@ -145,7 +145,7 @@ inline void LocalCoordinateCoding::Encode(const MatType& data, bool useCholesky = false; // Normalization and fitting and intercept are disabled. - const double tol = std::is_same::value ? + const double tol = std::is_same_v ? 1e-8 : 1e-16; LARS lars(useCholesky, 0.5 * lambda, 0, tol, false, false); diff --git a/src/mlpack/methods/logistic_regression/logistic_regression.hpp b/src/mlpack/methods/logistic_regression/logistic_regression.hpp index 37fddf2f15..6dd06dbd00 100644 --- a/src/mlpack/methods/logistic_regression/logistic_regression.hpp +++ b/src/mlpack/methods/logistic_regression/logistic_regression.hpp @@ -67,9 +67,9 @@ class LogisticRegression * @param lambda L2-regularization parameter. */ template::value>::type> + >::value>> LogisticRegression(const MatType& predictors, const arma::Row& responses, const double lambda = 0.0, @@ -91,9 +91,9 @@ class LogisticRegression * (L-BFGS). */ template::value>::type> + >::value>> LogisticRegression(const MatType& predictors, const arma::Row& responses, const RowType& initialPoint, @@ -117,12 +117,12 @@ class LogisticRegression */ template, RowType - >::value>::type, - typename = typename std::enable_if::value>, + typename = std::enable_if_t::value>::type> + >::value>> LogisticRegression(const MatType& predictors, const arma::Row& responses, OptimizerType& optimizer, @@ -147,12 +147,12 @@ class LogisticRegression */ template, RowType - >::value>::type, - typename = typename std::enable_if::value>, + typename = std::enable_if_t::value>::type> + >::value>> LogisticRegression(const MatType& predictors, const arma::Row& responses, OptimizerType& optimizer, @@ -179,9 +179,9 @@ class LogisticRegression */ template::value>::type> + >::value>> ElemType Train(const MatType& predictors, const arma::Row& responses, CallbackTypes&&... callbacks); @@ -206,9 +206,9 @@ class LogisticRegression */ template::value>::type> + >::value>> ElemType Train(const MatType& predictors, const arma::Row& responses, const double lambda, @@ -234,12 +234,12 @@ class LogisticRegression */ template, RowType - >::value>::type, - typename = typename std::enable_if::value>, + typename = std::enable_if_t::value>::type> + >::value>> ElemType Train(const MatType& predictors, const arma::Row& responses, OptimizerType& optimizer, @@ -266,12 +266,12 @@ class LogisticRegression */ template, RowType - >::value>::type, - typename = typename std::enable_if::value>, + typename = std::enable_if_t::value>::type> + >::value>> ElemType Train(const MatType& predictors, const arma::Row& responses, OptimizerType& optimizer, diff --git a/src/mlpack/methods/lsh/lsh_search_impl.hpp b/src/mlpack/methods/lsh/lsh_search_impl.hpp index 151c84f238..c45a9eebc2 100644 --- a/src/mlpack/methods/lsh/lsh_search_impl.hpp +++ b/src/mlpack/methods/lsh/lsh_search_impl.hpp @@ -647,8 +647,7 @@ void LSHSearch::GetAdditionalProbingBins( std::priority_queue< std::pair, // contents: pairs of (score, index) std::vector< // container: vector of pairs - std::pair - >, + std::pair>, std::greater< std::pair > // comparator of pairs > minHeap; // our minheap diff --git a/src/mlpack/methods/mean_shift/mean_shift.hpp b/src/mlpack/methods/mean_shift/mean_shift.hpp index 6316daa8b6..08e8507ecd 100644 --- a/src/mlpack/methods/mean_shift/mean_shift.hpp +++ b/src/mlpack/methods/mean_shift/mean_shift.hpp @@ -155,7 +155,7 @@ class MeanShift # @param centroid Store calculated centroid */ template - typename std::enable_if::type + std::enable_if_t CalculateCentroid(const MatType& data, const std::vector& neighbors, const std::vector& distances, @@ -170,7 +170,7 @@ class MeanShift # @param centroid Store calculated centroid */ template - typename std::enable_if::type + std::enable_if_t CalculateCentroid(const MatType& data, const std::vector& neighbors, const std::vector&, /*unused*/ diff --git a/src/mlpack/methods/mean_shift/mean_shift_impl.hpp b/src/mlpack/methods/mean_shift/mean_shift_impl.hpp index e3ea0dd09e..9c8faa7154 100644 --- a/src/mlpack/methods/mean_shift/mean_shift_impl.hpp +++ b/src/mlpack/methods/mean_shift/mean_shift_impl.hpp @@ -131,7 +131,7 @@ void MeanShift::GenSeeds(const MatType& data, // Calculate new centroid with given kernel. template template -typename std::enable_if::type +std::enable_if_t MeanShift::CalculateCentroid( const MatType& data, const std::vector& neighbors, @@ -163,7 +163,7 @@ MeanShift::CalculateCentroid( // Calculate new centroid by mean. template template -typename std::enable_if::type +std::enable_if_t MeanShift::CalculateCentroid( const MatType& data, const std::vector& neighbors, diff --git a/src/mlpack/methods/naive_bayes/naive_bayes_classifier_impl.hpp b/src/mlpack/methods/naive_bayes/naive_bayes_classifier_impl.hpp index 877079ae12..16343bc01c 100644 --- a/src/mlpack/methods/naive_bayes/naive_bayes_classifier_impl.hpp +++ b/src/mlpack/methods/naive_bayes/naive_bayes_classifier_impl.hpp @@ -35,7 +35,7 @@ NaiveBayesClassifier::NaiveBayesClassifier( trainingPoints(0), // Set when we call Train(). epsilon(epsilon) { - static_assert(std::is_same::value, + static_assert(std::is_same_v, "NaiveBayesClassifier: element type of given data must match the element " "type of the model!"); @@ -82,7 +82,7 @@ void NaiveBayesClassifier::Train( const size_t numClasses, const bool incremental) { - static_assert(std::is_same::value, + static_assert(std::is_same_v, "NaiveBayesClassifier: element type of given data must match the element " "type of the model!"); @@ -178,7 +178,7 @@ template void NaiveBayesClassifier::Train(const VecType& point, const size_t label) { - static_assert(std::is_same::value, + static_assert(std::is_same_v, "NaiveBayesClassifier: element type of given data must match the element " "type of the model!"); @@ -213,7 +213,7 @@ void NaiveBayesClassifier::LogLikelihood( const MatType& data, ModelMatType& logLikelihoods) const { - static_assert(std::is_same::value, + static_assert(std::is_same_v, "NaiveBayesClassifier: element type of given data must match the element " "type of the model!"); @@ -241,7 +241,7 @@ template template size_t NaiveBayesClassifier::Classify(const VecType& point) const { - static_assert(std::is_same::value, + static_assert(std::is_same_v, "NaiveBayesClassifier: element type of given data must match the element " "type of the model!"); @@ -270,11 +270,11 @@ void NaiveBayesClassifier::Classify( size_t& prediction, ProbabilitiesVecType& probabilities) const { - static_assert(std::is_same::value, + static_assert(std::is_same_v, "NaiveBayesClassifier: element type of given data must match the element " "type of the model!"); - static_assert(std::is_same::value, + static_assert(std::is_same_v, "NaiveBayesClassifier: element type of given data must match the element " "type of the model!"); @@ -312,7 +312,7 @@ void NaiveBayesClassifier::Classify( const MatType& data, arma::Row& predictions) const { - static_assert(std::is_same::value, + static_assert(std::is_same_v, "NaiveBayesClassifier: element type of given data must match the element " "type of the model!"); @@ -345,11 +345,11 @@ void NaiveBayesClassifier::Classify( arma::Row& predictions, ProbabilitiesMatType& predictionProbs) const { - static_assert(std::is_same::value, + static_assert(std::is_same_v, "NaiveBayesClassifier: element type of given data must match the element " "type of the model!"); - static_assert(std::is_same::value, + static_assert(std::is_same_v, "NaiveBayesClassifier: element type of given data must match the element " "type of the model!"); diff --git a/src/mlpack/methods/nca/nca.hpp b/src/mlpack/methods/nca/nca.hpp index fd66154b28..189e5236d5 100644 --- a/src/mlpack/methods/nca/nca.hpp +++ b/src/mlpack/methods/nca/nca.hpp @@ -80,12 +80,10 @@ class NCA * See https://www.ensmallen.org/docs.html#callback-documentation. */ template::value>::type, - typename = typename std::enable_if< - !FirstElementIsArma::value - >::type> + typename = std::enable_if_t::value>, + typename = std::enable_if_t< + !FirstElementIsArma::value>> [[deprecated("Will be removed in mlpack 5.0.0. Use the version that takes a " "dataset as a parameter.")]] void LearnDistance(arma::mat& outputMatrix, CallbackTypes&&... callbacks); @@ -106,14 +104,13 @@ class NCA template::type, SoftmaxErrorFunction, MatType - >::value>::type, - typename = typename std::enable_if::value>::type> + >::value>, + typename = std::enable_if_t< + IsEnsCallbackTypes::value>> void LearnDistance(const MatType& dataset, const LabelsType& labels, MatType& outputMatrix, @@ -137,11 +134,11 @@ class NCA typename LabelsType, typename OptimizerType, typename... CallbackTypes, - typename = typename std::enable_if, MatType - >::value>::type> + >::value>> void LearnDistance(const MatType& dataset, const LabelsType& labels, MatType& outputMatrix, diff --git a/src/mlpack/methods/pca/pca_impl.hpp b/src/mlpack/methods/pca/pca_impl.hpp index 865c968300..d4d4784036 100644 --- a/src/mlpack/methods/pca/pca_impl.hpp +++ b/src/mlpack/methods/pca/pca_impl.hpp @@ -47,8 +47,8 @@ void PCA::Apply(const MatType& data, "PCA::Apply(): transformedData must be a matrix type!"); static_assert(IsBaseMatType::value, "PCA::Apply(): eigVal must be a vector type!"); - static_assert(std::is_same::value, + static_assert(std::is_same_v, "PCA::Apply(): data and transformedData must have the same element " "types!"); @@ -81,8 +81,8 @@ void PCA::Apply(const MatType& data, "PCA::Apply(): transformedData must be a matrix type!"); static_assert(IsBaseMatType::value, "PCA::Apply(): eigVal must be a vector type!"); - static_assert(std::is_same::value, + static_assert(std::is_same_v, "PCA::Apply(): data and transformedData must have the same element " "types!"); @@ -104,8 +104,8 @@ void PCA::Apply(const MatType& data, // Sanity checks on input types. static_assert(IsBaseMatType::value, "PCA::Apply(): transformedData must be a matrix type!"); - static_assert(std::is_same::value, + static_assert(std::is_same_v, "PCA::Apply(): data and transformedData must have the same element " "types!"); diff --git a/src/mlpack/methods/perceptron/perceptron.hpp b/src/mlpack/methods/perceptron/perceptron.hpp index 1988d980b6..dccc250975 100644 --- a/src/mlpack/methods/perceptron/perceptron.hpp +++ b/src/mlpack/methods/perceptron/perceptron.hpp @@ -92,8 +92,8 @@ class Perceptron const size_t numClasses, const WeightsType& instanceWeights, const size_t maxIterations = 1000, - const typename std::enable_if< - arma::is_arma_type::value>::type* = 0); + const std::enable_if_t< + arma::is_arma_type::value>* = 0); /** * Alternate constructor which copies parameters from an already initiated @@ -114,8 +114,8 @@ class Perceptron const arma::Row& labels, const size_t numClasses, const WeightsType& instanceWeights, - const typename std::enable_if< - arma::is_arma_type::value>::type* = 0); + const std::enable_if_t< + arma::is_arma_type::value>* = 0); /** * Train the perceptron on the given data for up to the given maximum number diff --git a/src/mlpack/methods/perceptron/perceptron_impl.hpp b/src/mlpack/methods/perceptron/perceptron_impl.hpp index 28f02a8f4d..c03533889c 100644 --- a/src/mlpack/methods/perceptron/perceptron_impl.hpp +++ b/src/mlpack/methods/perceptron/perceptron_impl.hpp @@ -83,8 +83,7 @@ Perceptron::Perceptron( const size_t numClasses, const WeightsType& instanceWeights, const size_t maxIterations, - const typename std::enable_if< - arma::is_arma_type::value>::type*) : + const std::enable_if_t::value>*) : maxIterations(maxIterations) { // Start training. @@ -114,8 +113,7 @@ Perceptron::Perceptron( const arma::Row& labels, const size_t numClasses, const WeightsType& instanceWeights, - const typename std::enable_if< - arma::is_arma_type::value>::type*) : + const std::enable_if_t::value>*) : maxIterations(other.maxIterations) { TrainInternal(data, labels, numClasses, instanceWeights); diff --git a/src/mlpack/methods/softmax_regression/softmax_regression.hpp b/src/mlpack/methods/softmax_regression/softmax_regression.hpp index fb5f3b0c57..838bace925 100644 --- a/src/mlpack/methods/softmax_regression/softmax_regression.hpp +++ b/src/mlpack/methods/softmax_regression/softmax_regression.hpp @@ -93,12 +93,11 @@ class SoftmaxRegression */ template, DenseMatType - >::value>::type, - typename = typename std::enable_if::value>::type> + >::value>, + typename = std::enable_if_t< + IsEnsCallbackTypes::value>> SoftmaxRegression(const MatType& data, const arma::Row& labels, const size_t numClasses, @@ -125,12 +124,11 @@ class SoftmaxRegression */ template, DenseMatType - >::value>::type, - typename = typename std::enable_if::value>::type> + >::value>, + typename = std::enable_if_t< + IsEnsCallbackTypes::value>> SoftmaxRegression(const MatType& data, const arma::Row& labels, const size_t numClasses, @@ -158,15 +156,12 @@ class SoftmaxRegression template, DenseMatType - >::value>::type, - typename = typename std::enable_if< - std::is_class::value - >::type, - typename = typename std::enable_if::value>::type> + >::value>, + typename = std::enable_if_t>, + typename = std::enable_if_t< + IsEnsCallbackTypes::value>> [[deprecated("Will be removed in mlpack 5.0.0, use other Train() variants")]] double Train(const MatType& data, const arma::Row& labels, @@ -191,12 +186,11 @@ class SoftmaxRegression */ template, DenseMatType - >::value>::type, - typename = typename std::enable_if::value>::type> + >::value>, + typename = std::enable_if_t< + IsEnsCallbackTypes::value>> ElemType Train(const MatType& data, const arma::Row& labels, const size_t numClasses, @@ -221,12 +215,11 @@ class SoftmaxRegression */ template, DenseMatType - >::value>::type, - typename = typename std::enable_if::value>::type> + >::value>, + typename = std::enable_if_t< + IsEnsCallbackTypes::value>> ElemType Train(const MatType& data, const arma::Row& labels, const size_t numClasses, diff --git a/src/mlpack/tests/cv_test.cpp b/src/mlpack/tests/cv_test.cpp index b78e651f9d..f7c4f66625 100644 --- a/src/mlpack/tests/cv_test.cpp +++ b/src/mlpack/tests/cv_test.cpp @@ -299,8 +299,7 @@ void CheckPredictionsType() { using Extractor = MetaInfoExtractor; using ActualPT = typename Extractor::PredictionsType; - static_assert(std::is_same::value, - "Should be the same"); + static_assert(std::is_same_v, "Should be the same"); } /** @@ -350,8 +349,7 @@ void CheckWeightsType() { using Extractor = MetaInfoExtractor; using ActualWT = typename Extractor::WeightsType; - static_assert(std::is_same::value, - "Should be the same"); + static_assert(std::is_same_v, "Should be the same"); } /** diff --git a/src/mlpack/tests/distribution_test.cpp b/src/mlpack/tests/distribution_test.cpp index ac73f2ad8b..b1325d557c 100644 --- a/src/mlpack/tests/distribution_test.cpp +++ b/src/mlpack/tests/distribution_test.cpp @@ -454,7 +454,7 @@ TEMPLATE_TEST_CASE("GaussianUnivariateProbabilityTest", "[DistributionTest]", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 1e-4 : 1e-7; + const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-7; GaussianDistribution g(VecType("0.0"), MatType("1.0")); @@ -500,7 +500,7 @@ TEMPLATE_TEST_CASE("GaussianMultivariateProbabilityTest", "[DistributionTest]", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 1e-4 : 1e-7; + const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-7; // Simple case. VecType mean = "0 0"; @@ -611,7 +611,7 @@ TEMPLATE_TEST_CASE("GaussianDistributionRandomTest", "[DistributionTest]", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 0.3 : 0.125; + const ElemType tol = (std::is_same_v) ? 0.3 : 0.125; VecType mean("1.0 2.25"); MatType cov("0.85 0.60;" @@ -648,7 +648,7 @@ TEMPLATE_TEST_CASE("GaussianDistributionTrainTest", "[DistributionTest]", float, typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 1e-3 : 1e-5; + const ElemType tol = (std::is_same_v) ? 1e-3 : 1e-5; VecType mean("1.0 3.0 0.0 2.5"); MatType cov("3.0 0.0 1.0 4.0;" @@ -695,7 +695,7 @@ TEMPLATE_TEST_CASE("GaussianDistributionTrainWithProbabilitiesTest", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 0.25 : 0.1; + const ElemType tol = (std::is_same_v) ? 0.25 : 0.1; VecType mean = ("5.0"); VecType cov = ("2.0"); @@ -739,8 +739,8 @@ TEMPLATE_TEST_CASE("GaussianDistributionWithProbabilties1Test", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol1 = (std::is_same::value) ? 1e-10 : 1e-17; - const ElemType tol2 = (std::is_same::value) ? 1e-2 : 1e-4; + const ElemType tol1 = (std::is_same_v) ? 1e-10 : 1e-17; + const ElemType tol2 = (std::is_same_v) ? 1e-2 : 1e-4; VecType mean = ("5.0"); VecType cov = ("4.0"); @@ -891,7 +891,7 @@ TEMPLATE_TEST_CASE("GammaDistributionTrainWithProbabilitiesTest", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 0.03 : 0.015; + const ElemType tol = (std::is_same_v) ? 0.03 : 0.015; ElemType alphaReal = 5.4; ElemType betaReal = 6.7; @@ -986,7 +986,7 @@ TEMPLATE_TEST_CASE("GammaDistributionTrainTwoDistProbabilities1Test", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 0.25 : 0.075; + const ElemType tol = (std::is_same_v) ? 0.25 : 0.075; ElemType alphaReal = 5.4; ElemType betaReal = 6.7; @@ -1275,7 +1275,7 @@ TEMPLATE_TEST_CASE("DiscreteDistributionTest", "[DistributionTest]", typedef typename arma::Col ObsVecType; typedef typename arma::Mat ObsMatType; - const ElemType tol = (std::is_same::value) ? 1e-4 : 1e-8; + const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-8; // I assume that I am properly saving vectors, so, this should be // straightforward. @@ -1600,7 +1600,7 @@ TEMPLATE_TEST_CASE("DiagonalGaussianUnivariateProbabilityTest", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 1e-4 : 1e-7; + const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-7; DiagonalGaussianDistribution d(VecType("0.0"), VecType("1.0")); @@ -1640,7 +1640,7 @@ TEMPLATE_TEST_CASE("DiagonalGaussianMultivariateProbabilityTest", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 1e-4 : 1e-7; + const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-7; VecType mean("0 0"); VecType cov("2 2"); @@ -1706,7 +1706,7 @@ TEMPLATE_TEST_CASE("DiagonalGaussianDistributionRandomTest", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 0.2 : 0.1; + const ElemType tol = (std::is_same_v) ? 0.2 : 0.1; VecType mean("2.5 1.25"); VecType cov("0.50 0.25"); @@ -1739,7 +1739,7 @@ TEMPLATE_TEST_CASE("DiagonalGaussianDistributionTrainTest", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 1e-3 : 1e-5; + const ElemType tol = (std::is_same_v) ? 1e-3 : 1e-5; VecType mean("2.5 1.5 8.2 3.1"); VecType cov("1.2 3.1 8.3 4.3"); @@ -1778,7 +1778,7 @@ TEMPLATE_TEST_CASE("DiagonalGaussianUnbiasedEstimatorTest", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 1e-4 : 1e-7; + const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-7; // Generate the observations. MatType observations("3 5 2 7;" @@ -1816,7 +1816,7 @@ TEMPLATE_TEST_CASE("DiagonalGaussianWeightedParametersReductionTest", typedef typename arma::Col VecType; typedef typename arma::Mat MatType; - const ElemType tol = (std::is_same::value) ? 1e-4 : 1e-7; + const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-7; VecType mean("2.5 1.5 8.2 3.1"); VecType cov("1.2 3.1 8.3 4.3"); diff --git a/src/mlpack/tests/lars_test.cpp b/src/mlpack/tests/lars_test.cpp index 196e6c23c7..95220bccff 100644 --- a/src/mlpack/tests/lars_test.cpp +++ b/src/mlpack/tests/lars_test.cpp @@ -35,7 +35,7 @@ void LARSVerifyCorrectness(const VecType& beta, size_t nDims = beta.n_elem; // floats require a much larger tolerance. - const ElemType tol = (std::is_same::value) ? 1e-8 : 5e-3; + const ElemType tol = (std::is_same_v) ? 1e-8 : 5e-3; for (size_t j = 0; j < nDims; ++j) { @@ -1226,7 +1226,7 @@ TEMPLATE_TEST_CASE("LARSSelectBetaTest", "[LARSTest]", arma::fmat, arma::mat) typedef TestType MatType; typedef typename MatType::elem_type ElemType; - const ElemType tol = (std::is_same::value) ? 1e-5 : 5e-3; + const ElemType tol = (std::is_same_v) ? 1e-5 : 5e-3; // Train a model on a randomly generated problem. Then, we will iterate // through different selected lambda values, ensuring that the error on the @@ -1244,8 +1244,7 @@ TEMPLATE_TEST_CASE("LARSSelectBetaTest", "[LARSTest]", arma::fmat, arma::mat) // Now step through numerous different lambda values. ElemType lastError = std::numeric_limits::max(); - const ElemType errorTol = (std::is_same::value) ? 1e-8 : - 0.05; + const ElemType errorTol = (std::is_same_v) ? 1e-8 : 0.05; for (ElemType i = 5.0; i >= -5.0; i -= 0.1) { const ElemType selLambda1 = std::pow(10.0, (ElemType) i); diff --git a/src/mlpack/tests/lmnn_test.cpp b/src/mlpack/tests/lmnn_test.cpp index 394474511b..5192483972 100644 --- a/src/mlpack/tests/lmnn_test.cpp +++ b/src/mlpack/tests/lmnn_test.cpp @@ -116,8 +116,8 @@ TEMPLATE_TEST_CASE("LMNNInitialPointTest", "[LMNNTest]", float, double) LMNNFunction> lmnnfn(dataset, labels, 1, 0.5, 1); // Verify the initial point is the identity matrix. - const double eps = std::is_same::value ? 1e-4 : 1e-7; - const double margin = std::is_same::value ? 1e-4 : 1e-5; + const double eps = std::is_same_v ? 1e-4 : 1e-7; + const double margin = std::is_same_v ? 1e-4 : 1e-5; arma::Mat initialPoint = lmnnfn.GetInitialPoint(); for (int row = 0; row < 5; row++) { @@ -148,7 +148,7 @@ TEMPLATE_TEST_CASE("LMNNInitialEvaluationTest", "[LMNNTest]", float, double) ElemType objective = lmnnfn.Evaluate(arma::eye>(2, 2)); // Result calculated by hand. - const double eps = std::is_same::value ? 1e-4 : 1e-7; + const double eps = std::is_same_v ? 1e-4 : 1e-7; REQUIRE(objective == Approx(9.456).epsilon(eps)); } @@ -171,8 +171,8 @@ TEMPLATE_TEST_CASE("LMNNInitialGradientTest", "[LMNNTest]", float, double) lmnnfn.Gradient(coordinates, gradient); // Result calculated by hand. - const double eps = std::is_same::value ? 1e-4 : 1e-7; - const double margin = std::is_same::value ? 1e-4 : 1e-5; + const double eps = std::is_same_v ? 1e-4 : 1e-7; + const double margin = std::is_same_v ? 1e-4 : 1e-5; REQUIRE(gradient(0, 0) == Approx(-0.288).epsilon(eps)); REQUIRE(gradient(1, 0) == Approx(0.0).margin(margin)); REQUIRE(gradient(0, 1) == Approx(0.0).margin(margin)); @@ -198,8 +198,8 @@ TEMPLATE_TEST_CASE("LMNNInitialEvaluateWithGradientTest", "[LMNNTest]", float, arma::Mat coordinates = arma::eye>(2, 2); ElemType objective = lmnnfn.EvaluateWithGradient(coordinates, gradient); - const double eps = std::is_same::value ? 1e-4 : 1e-7; - const double margin = std::is_same::value ? 1e-4 : 1e-5; + const double eps = std::is_same_v ? 1e-4 : 1e-7; + const double margin = std::is_same_v ? 1e-4 : 1e-5; // Result calculated by hand. REQUIRE(objective == Approx(9.456).epsilon(eps)); @@ -225,7 +225,7 @@ TEMPLATE_TEST_CASE("LMNNSeparableObjectiveTest", "[LMNNTest]", float, double) LMNNFunction> lmnnfn(dataset, labels, 1, 0.6, 1); // Result calculated by hand. - const double eps = std::is_same::value ? 1e-4 : 1e-7; + const double eps = std::is_same_v ? 1e-4 : 1e-7; arma::Mat coordinates = arma::eye>(2, 2); REQUIRE(lmnnfn.Evaluate(coordinates, 0, 1) == Approx(1.576).epsilon(eps)); REQUIRE(lmnnfn.Evaluate(coordinates, 1, 1) == Approx(1.576).epsilon(eps)); @@ -254,8 +254,8 @@ TEMPLATE_TEST_CASE("LMNNSeparableGradientTest", "[LMNNTest]", float, double) lmnnfn.Gradient(coordinates, 0, gradient, 1); - const double eps = std::is_same::value ? 1e-4 : 1e-7; - const double margin = std::is_same::value ? 1e-4 : 1e-5; + const double eps = std::is_same_v ? 1e-4 : 1e-7; + const double margin = std::is_same_v ? 1e-4 : 1e-5; REQUIRE(gradient(0, 0) == Approx(-0.048).epsilon(eps)); REQUIRE(gradient(0, 1) == Approx(0.0).margin(margin)); @@ -318,8 +318,8 @@ TEMPLATE_TEST_CASE("LMNNSeparableEvaluateWithGradientTest", "[LMNNTest]", float, ElemType objective = lmnnfn.EvaluateWithGradient(coordinates, 0, gradient, 1); - const double eps = std::is_same::value ? 1e-4 : 1e-7; - const double margin = std::is_same::value ? 1e-4 : 1e-5; + const double eps = std::is_same_v ? 1e-4 : 1e-7; + const double margin = std::is_same_v ? 1e-4 : 1e-5; REQUIRE(objective == Approx(1.576).epsilon(eps)); diff --git a/src/mlpack/tests/main_tests/main_test_fixture.hpp b/src/mlpack/tests/main_tests/main_test_fixture.hpp index 44ba2642e2..1b7357513b 100644 --- a/src/mlpack/tests/main_tests/main_test_fixture.hpp +++ b/src/mlpack/tests/main_tests/main_test_fixture.hpp @@ -106,8 +106,7 @@ class MainTestFixture template void SetInputParam(const std::string& name, T&& value) { - params.Get::type>(name) = - std::forward(value); + params.Get>(name) = std::forward(value); params.SetPassed(name); } diff --git a/src/mlpack/tests/nca_test.cpp b/src/mlpack/tests/nca_test.cpp index f618363404..09024d67ec 100644 --- a/src/mlpack/tests/nca_test.cpp +++ b/src/mlpack/tests/nca_test.cpp @@ -41,8 +41,8 @@ TEMPLATE_TEST_CASE("SoftmaxInitialPoint", "[NCATest]", float, double) // Verify the initial point is the identity matrix. arma::Mat initialPoint = sef.GetInitialPoint(); - const double eps = std::is_same::value ? 1e-4 : 1e-7; - const double margin = std::is_same::value ? 1e-4 : 1e-5; + const double eps = std::is_same_v ? 1e-4 : 1e-7; + const double margin = std::is_same_v ? 1e-4 : 1e-5; for (int row = 0; row < 5; row++) { for (int col = 0; col < 5; col++) @@ -131,7 +131,7 @@ TEMPLATE_TEST_CASE("SoftmaxOptimalEvaluation", "[NCATest]", float, double) // Use a very close tolerance for optimality; we need to be sure this function // gives optimal results correctly. - const double eps = std::is_same::value ? 1e-6 : 1e-12; + const double eps = std::is_same_v ? 1e-6 : 1e-12; REQUIRE(objective == Approx(-4.0).epsilon(eps)); } diff --git a/src/mlpack/tests/pca_test.cpp b/src/mlpack/tests/pca_test.cpp index 4957280df4..2878913e2c 100644 --- a/src/mlpack/tests/pca_test.cpp +++ b/src/mlpack/tests/pca_test.cpp @@ -361,7 +361,7 @@ TEMPLATE_TEST_CASE("PCASubviewTest", "[PCATest]", ExactSVDPolicy, p.Apply(data.cols(0, 1999), transData3, eigval2, eigvec); // Only check for deterministic policies. - if (std::is_same::value) + if (std::is_same_v) { arma::mat trueTransData, trueEigvec; arma::vec trueEigval; @@ -408,7 +408,7 @@ TEMPLATE_TEST_CASE("PCAExpressionTest", "[PCATest]", ExactSVDPolicy, p.Apply(2 * data + 1, transData3, eigval2, eigvec); // Only check for deterministic policies. - if (std::is_same::value) + if (std::is_same_v) { arma::mat trueTransData, trueEigvec; arma::vec trueEigval; @@ -456,7 +456,7 @@ TEMPLATE_TEST_CASE("PCAFloatTest", "[PCATest]", ExactSVDPolicy, // Verify the PCA results based on the eigenvalues. We don't check for // QUIC-SVD, since that method has a lot of noise. - if (!std::is_same::value) + if (!std::is_same_v) { for (size_t i = 0; i < eigVal.n_elem; ++i) { diff --git a/src/mlpack/tests/sparse_coding_test.cpp b/src/mlpack/tests/sparse_coding_test.cpp index fa22dbc9cc..0a732cf2a5 100644 --- a/src/mlpack/tests/sparse_coding_test.cpp +++ b/src/mlpack/tests/sparse_coding_test.cpp @@ -23,7 +23,7 @@ void SCVerifyCorrectness(const VecType& beta, const VecType& errCorr, double lambda) { - const double tol = std::is_same::value ? + const double tol = std::is_same_v ? 1e-6 : 1e-12; size_t nDims = beta.n_elem; for (size_t j = 0; j < nDims; ++j) @@ -122,7 +122,7 @@ TEMPLATE_TEST_CASE("SparseCodingTestDictionaryStep", "[SparseCodingTest]", { typedef TestType MatType; - const double tol = std::is_same::value ? + const double tol = std::is_same_v ? 0.01 : 1e-6; double lambda1 = 0.1; @@ -215,7 +215,7 @@ TEMPLATE_TEST_CASE("SparseCodingTrainReturnObjective", "[SparseCodingTest]", { typedef TestType MatType; - const double tol = std::is_same::value ? + const double tol = std::is_same_v ? 0.01 : 1e-6; double lambda1 = 0.1; diff --git a/src/mlpack/tests/test_catch_tools.hpp b/src/mlpack/tests/test_catch_tools.hpp index 288cd26075..229063ab9e 100644 --- a/src/mlpack/tests/test_catch_tools.hpp +++ b/src/mlpack/tests/test_catch_tools.hpp @@ -23,8 +23,8 @@ // Simple wrapper class to prevent copies of Armadillo matrices. template ::value>> + typename = std::enable_if_t>> class MatProxy { public: @@ -54,9 +54,9 @@ class MatProxy, ElemType> template ::value && arma::is_arma_type::value - && std::is_same::value - && !std::is_integral::value>> + && std::is_same_v + && !std::is_integral_v>> inline void CheckMatrices(const MatTypeA& _a, const MatTypeB& _b, double tolerance = 1e-5) @@ -103,8 +103,8 @@ inline void CheckFields(const FieldType& a, // Simple wrapper class to prevent copies of Armadillo cubes. template ::value>> + typename = std::enable_if_t>> class CubeProxy { public: @@ -136,9 +136,9 @@ class CubeProxy, ElemType> template ::value && arma::is_arma_cube_type::value - && std::is_same::value - && !std::is_integral::value>, + && std::is_same_v + && !std::is_integral_v>, typename = void> inline void CheckMatrices(const CubeTypeA& _a, const CubeTypeB& _b, diff --git a/src/mlpack/tests/ub_tree_test.cpp b/src/mlpack/tests/ub_tree_test.cpp index fbd134535a..baf811019d 100644 --- a/src/mlpack/tests/ub_tree_test.cpp +++ b/src/mlpack/tests/ub_tree_test.cpp @@ -19,9 +19,9 @@ using namespace mlpack; TEST_CASE("AddressTest", "[UBTreeTest]") { typedef double ElemType; - typedef typename std::conditional::type AddressElemType; + uint64_t> AddressElemType; arma::Mat dataset(8, 1000); dataset.randu(); @@ -44,9 +44,9 @@ template void CheckSplit(const TreeType& tree) { typedef typename TreeType::ElemType ElemType; - typedef typename std::conditional::type AddressElemType; + uint64_t> AddressElemType; if (tree.IsLeaf()) return;