Releases: rollbear/strong_type
v15
-
CMake package is now
ARCH_INDEPENDENT, as it should be when it's
header only. Thank you @PatrickKa for submitting the fix. -
Much reworked
strong::range, which is now compatible with
std::ranges. This was primarily sparked by a discussion with
Harald Achitz. Thank you for bringing up the deficiencies.
v14
-
Added several missing
[[nodiscard]] -
.begin()and.end()are nowconstexprforstrong::rangetypes. Thanks Harald Achitz for reporting the missing specifiers. -
Added
.size()member tostrong::rangetypes, if the underlying type has a.size()member. Thanks Harald Achitz for the suggestion.
v13
-
Added
static_assert()messages explaining why a modifier cannot be
used with an underlying type. Thank you @SilmaliTech for suggesting
the improvement. -
Added modifier
invocablefor types withoperator(). Thank you
@DNKpp for the suggestion and the draft implementation.
v12
-
Fixed a bug where
fmtformatter function was notconst, as it must be
per the documentation. Thank you Tim Blechmann for submitting the
fix. -
Strong types can be
weakly_ordered,strongly_orderedand
partially_ordered, using operator<=>in C++20 and later. Huge thanks
to Björn Schäpers and Tim Blechmann for the suggestions, discussions
and infinite patience.
v11
- A strong type can now be used as an NTTP (Non Type Template Parameter)
Thank you Toni Neubert for the implementation.
using type = strong::type<int, struct int_>; template <type t> struct S { constexpr operator int() const { return value_of(t);} }; int main() { S<type{3}> obj; return obj; }
v10
- Corrected the test for, and use of, concepts when specializing
std::numeric_limits<>forstrong::arithmetictypes. Thank you
@HazardyKnusperkeks for reporting.
v9
-
Lowered the minimum required CMake version to 3.7, unless unit-tests
are built. -
A type predicate
strong::type_is_v<type, modifier>has been introduced.
It can be used in compile time tests for generic code to ensure that
a strong type has the necessary modifiers. Example:using type = strong::type<int, struct type_, strong::ordered, strong::ordered_with<int, long>>; static_assert(strong::type_is_v<type, strong::ordered>); static_assert(strong::type_is_v<type, strong::ordered_with<long>>);
Note that for variadic modifiers like
strong::ordered_with<>, the
predicate ensures that all types listed in the test are supported,
so in the example above, the testtype_is_v<type, ordered_with<long>>
is true because 'long' is included in the type definition using
ordered_with<int, long>.There's also a type version, to use as
strong::is_type<type, modifier>::value; -
std::numeric_limits<T>is specialized for types using the
strong::arithmetic modifier. -
Added missing
const&&overloads forvalue_of()
v8
-
Split the header file into one file for each modifier. This can
in some cases speed up compilation times considerably. The header
file<strong_type/strong_type.hpp>still includes everything, so
no changes to existing code is necessary. -
Added new modifier
scalable_with<Ts...>. Allows multiplication and
division with each of the typesTs. If the underlying type can be
divided, the result will be the first of the type inTs. -
difference types are conditionally ordered, if the underlying type
supports it. Previously they were always ordered, but e.g. a 2D
vector on a plane is a useful difference type, but it is usually
not ordered. This change allows the vector in 2D space to be used
as a difference type. -
Add CMake alias target
strong_type::strong_type -
Use the CMake option
-DSTRONG_TYPE_UNIT_TEST=yesto build unit tests
v7
v6
- Added missing
strong::is_ostreamable<>predicate needed for fmtlib 9. Thank you Tim Blechman @timblechmann for submitting the fix.