Closed Alex-Muirhead closed 6 months ago
An unintended side-effect of this trait is that more types implement opCast!double
than previously expected, including bool
, int
, and char
. This should be taken into consideration as, while they would store the value correctly (as far as D is concerned), it does introduce duplication of effects for the existing lua_pushinteger
and lua_pushboolean
(although the former uses type size_t
).
The
util
files are currently intertwined with thentypes
files through theComplex
datatype, as sometimes we need to call Lua binding functions with eitherdouble
s orComplex!double
s. This also causes a duplication of some Lua bindings & functions. With the potential introduction ofDual
numbers as an alternative adjoint computation method, this would introduce more duplication.This merge proposes the use of limited templates, to remove the duplication, and allow for the
util
files to be decoupled from specific number types. The traitcanCastTo
is introduced, which allows compile-time checks if a type can be cast to another, either explicitly (using thecast(T)
orto!(T)
notation) or implicitly (by sub-typing). This is similar to the traitsisFloating
andisIntegral
, however those cannot be extended to user-defined types.