jk-jeon / dragonbox

Reference implementation of Dragonbox in C++
Apache License 2.0
588 stars 37 forks source link

nvcc (Version 201402L) throws "error: namespace "std" has no member "is_same_v" #49

Closed dirk8b closed 10 months ago

dirk8b commented 10 months ago

Hi, I am trying to test dragonbox with the nvcc compiler (Version 201402L). But it throws;

  1. dragonbox/dragonbox_to_chars.h(98): error: namespace "std" has no member "is_same_v" std::is_same_v<FloatFormat, ieee754_binary32>
  2. dragonbox/dragonbox_to_chars.h(98): error: type name is not allowed std::is_same_v<FloatFormat, ieee754_binary32>
  3. dragonbox/dragonbox_to_chars.h(98): error: expected a ";" std::is_same_v<FloatFormat, ieee754_binary32>

I only include dragonbox_to_chars.h in my test code (I have to write millions of float numbers to a csv file with high performance. std::to_string and fprintf are far to slow.).

In my understanding and looking into the dragonbox code it should work with this nvcc version.

Where is the knot in the head?

Thank you!

jk-jeon commented 10 months ago

The library used to require C++17. I recently did some big overhaul to make it C++11 compatible, but this was a thing that I missed. With the recent commit 9a7e3fc this should be fixed now.

Thank you for reporting the issue, and please feel free to post additional compatibility issues if you find anything.

dirk8b commented 10 months ago

Thank you, but there are warnings and errors again:

I have a very tiny testcode (no output so far) for this: int main() { constexpr int buffer_length = 21; jkj::dragonbox::max_output_string_length; double x = 1.234; char buffer[buffer_length]; char* end_ptr = jkj::dragonbox::to_chars(x, buffer); }

I will use a lookup table for the conversion now. I think there is no faster way if the numbers are very limited (-1000.00 till + 1000.00 in my case).

Have a nice weekend

jk-jeon commented 10 months ago

I believe the recent commit (b5ba69256b00d35f3f3df79042600fdf41098f88) now fixed it. Thank you very much for the report!