-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xo-unit: refactor: move promoter aux class to detail/ subdir
- Loading branch information
Showing
2 changed files
with
47 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** @file promoter.hpp | ||
* | ||
* Author: Roland Conybeare | ||
**/ | ||
|
||
#pragma once | ||
|
||
#include "unit.hpp" | ||
|
||
namespace xo { | ||
namespace unit { | ||
/** @class promoter | ||
* | ||
* Auxiliary class driver for quantity::promote(). | ||
* promoter has two specializations: | ||
* 1. if Unit is dimensionless, @c promoter::promote() is the identity function. | ||
* This has the effect of collapsing dimensionless quantities to their representation. | ||
* 2. if Unit has at least one non-empty dimension, | ||
* @c promoter::promote() builds an xo::unit::quantity instance | ||
**/ | ||
template <typename Unit, typename Repr, bool Dimensionless = dimensionless_v<Unit> > | ||
struct promoter; | ||
|
||
template <typename Unit, typename Repr> | ||
class quantity; | ||
|
||
/* collapse dimensionless quantity to its repr_type> */ | ||
template <typename Unit, typename Repr> | ||
struct promoter<Unit, Repr, /*Dimensionless*/ true> { | ||
static constexpr Repr promote(Repr x) { return x; }; | ||
}; | ||
|
||
template <typename Unit, typename Repr> | ||
struct promoter<Unit, Repr, /*Dimensionless*/ false> { | ||
static constexpr quantity<Unit, Repr> promote(Repr x) { return quantity<Unit, Repr>(x); } | ||
}; | ||
} /*namespace unit*/ | ||
} /*namespace xo*/ | ||
|
||
/** end promoter.hpp **/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters