Closed adam-nielsen closed 7 years ago
i 'm "apprentice" in c++, for my understanding, the definition of long long in 32bits or 64bits systems is done by the compiler of the system hardware, you hope to remove the template and let the compiler do the job, to be more portable by the using of std::uintxx_t , std::intxx_t as std::int128_t of the
Sort of. The problem is that being a template
, with no generic implementation and only a collection of specialisations, is that as soon as you try to call the function with a data type that hasn't been implemented you get an error. The compiler tries to call the generic implementation and it's not until link time that it realises it can't find it.
By telling the compiler that there is no generic implementation (removing the template
part) it will fail at compile time if it cannot find a matching function instead. It should also convert automatically between similar types like long long
and int64_t
, which some compilers (like GCC) don't do for some reason when they are templates.
Nice discussion. To be honest, this was some of the earliest code I wrote for this project, and I probably didn't spend enough time thinking about how it should look. I agree that it probably makes since to make it a non-template function. Since all numbers are stored internally as a long double
, it may be possible to come up with a generic implementation. I'll do a bit of research on how other libraries handle this over the weekend and then commit a solution.
Possibly related to #105, which seemed to undo the fix for #5, I am getting errors using the library under Linux again:
Rather than redo the fix from #5 (adjusted for #105), I am wondering why
cell::value(...)
is atemplate
at all. If an implementation needs to be supplied for every single data type, wouldn't it be better to remove thetemplate
and make it an overloaded function instead? Then the compiler would just pick theint64_t
version when given along long
.I haven't looked too closely though, so perhaps this isn't possible.