From a9baab76c27704467df03bcf2a30ec463207b4b4 Mon Sep 17 00:00:00 2001
From: Niels Lohmann <mail@nlohmann.me>
Date: Wed, 28 Mar 2018 18:20:55 +0200
Subject: [PATCH 1/7] :ambulance: fix for #1021

---
 include/nlohmann/detail/exceptions.hpp        |  1 +
 .../nlohmann/detail/output/binary_writer.hpp  | 50 +++++++++++++++---
 single_include/nlohmann/json.hpp              | 51 ++++++++++++++++---
 test/src/unit-regression.cpp                  | 18 +++++++
 4 files changed, 108 insertions(+), 12 deletions(-)

diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp
index b73d7b1f..53b38ec8 100644
--- a/include/nlohmann/detail/exceptions.hpp
+++ b/include/nlohmann/detail/exceptions.hpp
@@ -301,6 +301,7 @@ Exceptions have ids 5xx.
 name / id                      | example message | description
 ------------------------------ | --------------- | -------------------------
 json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed.
+json.exception.other_error.502 | type for number_float_t is not supported | The template type for a number is not supported for the binary serialization in CBOR, MessagePack or UBJSON.
 
 @sa @ref exception for the base class of the library exceptions
 @sa @ref parse_error for exceptions indicating a parse error
diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp
index 1b15bdaf..13968fed 100644
--- a/include/nlohmann/detail/output/binary_writer.hpp
+++ b/include/nlohmann/detail/output/binary_writer.hpp
@@ -149,9 +149,19 @@ class binary_writer
                 break;
             }
 
-            case value_t::number_float: // Double-Precision Float
+            case value_t::number_float:
             {
-                oa->write_character(static_cast<CharType>(0xFB));
+                switch (sizeof(typename BasicJsonType::number_float_t))
+                {
+                    case 4:  // Single-Precision Float
+                        oa->write_character(static_cast<CharType>(0xFA));
+                        break;
+                    case 8:  // Double-Precision Float
+                        oa->write_character(static_cast<CharType>(0xFB));
+                        break;
+                    default:
+                        JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
+                }
                 write_number(j.m_value.number_float);
                 break;
             }
@@ -409,9 +419,19 @@ class binary_writer
                 break;
             }
 
-            case value_t::number_float: // float 64
+            case value_t::number_float:
             {
-                oa->write_character(static_cast<CharType>(0xCB));
+                switch (sizeof(typename BasicJsonType::number_float_t))
+                {
+                    case 4:  // float 32
+                        oa->write_character(static_cast<CharType>(0xCA));
+                        break;
+                    case 8:  // float 64
+                        oa->write_character(static_cast<CharType>(0xCB));
+                        break;
+                    default:
+                        JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
+                }
                 write_number(j.m_value.number_float);
                 break;
             }
@@ -712,7 +732,17 @@ class binary_writer
     {
         if (add_prefix)
         {
-            oa->write_character(static_cast<CharType>('D'));  // float64
+            switch (sizeof(typename BasicJsonType::number_float_t))
+            {
+                case 4:  // float 32
+                    oa->write_character(static_cast<CharType>('d'));
+                    break;
+                case 8:  // float 64
+                    oa->write_character(static_cast<CharType>('D'));
+                    break;
+                default:
+                    JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
+            }
         }
         write_number(n);
     }
@@ -892,7 +922,15 @@ class binary_writer
             }
 
             case value_t::number_float:
-                return 'D';
+                switch (sizeof(typename BasicJsonType::number_float_t))
+                {
+                    case 4:  // float 32
+                        return 'd';
+                    case 8:  // float 64
+                        return 'D';
+                    default:
+                        JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
+                }
 
             case value_t::string:
                 return 'S';
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index 6b6655af..deeb9d5d 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -794,6 +794,7 @@ Exceptions have ids 5xx.
 name / id                      | example message | description
 ------------------------------ | --------------- | -------------------------
 json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed.
+json.exception.other_error.502 | type for number_float_t is not supported | The template type for a number is not supported for the binary serialization in CBOR, MessagePack or UBJSON.
 
 @sa @ref exception for the base class of the library exceptions
 @sa @ref parse_error for exceptions indicating a parse error
@@ -6357,9 +6358,19 @@ class binary_writer
                 break;
             }
 
-            case value_t::number_float: // Double-Precision Float
+            case value_t::number_float:
             {
-                oa->write_character(static_cast<CharType>(0xFB));
+                switch (sizeof(typename BasicJsonType::number_float_t))
+                {
+                    case 4:  // Single-Precision Float
+                        oa->write_character(static_cast<CharType>(0xFA));
+                        break;
+                    case 8:  // Double-Precision Float
+                        oa->write_character(static_cast<CharType>(0xFB));
+                        break;
+                    default:
+                        JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
+                }
                 write_number(j.m_value.number_float);
                 break;
             }
@@ -6617,9 +6628,19 @@ class binary_writer
                 break;
             }
 
-            case value_t::number_float: // float 64
+            case value_t::number_float:
             {
-                oa->write_character(static_cast<CharType>(0xCB));
+                switch (sizeof(typename BasicJsonType::number_float_t))
+                {
+                    case 4:  // float 32
+                        oa->write_character(static_cast<CharType>(0xCA));
+                        break;
+                    case 8:  // float 64
+                        oa->write_character(static_cast<CharType>(0xCB));
+                        break;
+                    default:
+                        JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
+                }
                 write_number(j.m_value.number_float);
                 break;
             }
@@ -6920,7 +6941,17 @@ class binary_writer
     {
         if (add_prefix)
         {
-            oa->write_character(static_cast<CharType>('D'));  // float64
+            switch (sizeof(typename BasicJsonType::number_float_t))
+            {
+                case 4:  // float 32
+                    oa->write_character(static_cast<CharType>('d'));
+                    break;
+                case 8:  // float 64
+                    oa->write_character(static_cast<CharType>('D'));
+                    break;
+                default:
+                    JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
+            }
         }
         write_number(n);
     }
@@ -7100,7 +7131,15 @@ class binary_writer
             }
 
             case value_t::number_float:
-                return 'D';
+                switch (sizeof(typename BasicJsonType::number_float_t))
+                {
+                    case 4:  // float 32
+                        return 'd';
+                    case 8:  // float 64
+                        return 'D';
+                    default:
+                        JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
+                }
 
             case value_t::string:
                 return 'S';
diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp
index c4ca93d9..faa38a14 100644
--- a/test/src/unit-regression.cpp
+++ b/test/src/unit-regression.cpp
@@ -114,6 +114,13 @@ struct nocopy
 };
 }
 
+/////////////////////////////////////////////////////////////////////
+// for #1021
+/////////////////////////////////////////////////////////////////////
+
+using float_json = nlohmann::basic_json<std::map, std::vector, std::string, bool, std::int32_t, std::uint32_t, float>;
+
+
 TEST_CASE("regression tests")
 {
     SECTION("issue #60 - Double quotation mark is not parsed correctly")
@@ -1597,4 +1604,15 @@ TEST_CASE("regression tests")
         auto j = json::parse(geojsonExample, cb, true);
         CHECK(j == json());
     }
+
+    SECTION("issue #1021 - to/from_msgpack only works with standard typization")
+    {
+        float_json j = 1000.0;
+        CHECK(float_json::from_cbor(float_json::to_cbor(j)) == j);
+        CHECK(float_json::from_msgpack(float_json::to_msgpack(j)) == j);
+        CHECK(float_json::from_ubjson(float_json::to_ubjson(j)) == j);
+
+        float_json j2 = {1000.0, 2000.0, 3000.0};
+        CHECK(float_json::from_ubjson(float_json::to_ubjson(j2, true, true)) == j2);
+    }
 }

From 73cc5089e33ea950b6677e19ee7ec656c9bcf985 Mon Sep 17 00:00:00 2001
From: Kevin Tonon <nobigb@gmial.com>
Date: Tue, 27 Mar 2018 12:51:30 -0400
Subject: [PATCH 2/7] Using target_compile_features to specify C++ 11 standard

---
 CMakeLists.txt            | 4 +++-
 benchmarks/CMakeLists.txt | 5 +++--
 test/CMakeLists.txt       | 8 +++-----
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c0acc750..958a129f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.0.0)
+cmake_minimum_required(VERSION 3.8)
 
 ##
 ## PROJECT
@@ -44,6 +44,8 @@ endif()
 ##
 add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE)
 
+target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11)
+
 target_include_directories(
     ${NLOHMANN_JSON_TARGET_NAME}
     INTERFACE
diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt
index c10d44e9..a53812c1 100644
--- a/benchmarks/CMakeLists.txt
+++ b/benchmarks/CMakeLists.txt
@@ -1,9 +1,9 @@
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.8)
 project(JSON_Benchmarks LANGUAGES CXX)
 
 # set compiler flags
 if((CMAKE_CXX_COMPILER_ID MATCHES GNU) OR (CMAKE_CXX_COMPILER_ID MATCHES Clang))
-   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -flto -DNDEBUG -O3")
+   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -DNDEBUG -O3")
 endif()
 
 # configure Google Benchmarks
@@ -23,4 +23,5 @@ file(COPY ${CMAKE_SOURCE_DIR}/../test/data/regression/floats.json
 
 # benchmark binary
 add_executable(json_benchmarks src/benchmarks.cpp)
+target_compile_features(json_benchmarks PRIVATE cxx_std_11)
 target_link_libraries(json_benchmarks benchmark ${CMAKE_THREAD_LIBS_INIT})
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index e5f6dc55..c49150ad 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -6,7 +6,7 @@ option(JSON_Coverage "Build test suite with coverage information" OFF)
 if(JSON_Sanitizer)
     message(STATUS "Building test suite with Clang sanitizer")
     if(NOT MSVC)
-        set(CMAKE_CXX_FLAGS "-std=c++11 -g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer")
+        set(CMAKE_CXX_FLAGS "-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer")
     endif()
 endif()
 
@@ -62,11 +62,10 @@ add_library(catch_main OBJECT
     "src/unit.cpp"
 )
 set_target_properties(catch_main PROPERTIES
-    CXX_STANDARD 11
-    CXX_STANDARD_REQUIRED ON
     COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>"
     COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>"
 )
+target_compile_features(catch_main PUBLIC cxx_std_11)
 target_include_directories(catch_main PRIVATE "thirdparty/catch")
 
 # https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake
@@ -96,13 +95,12 @@ foreach(file ${files})
 
     add_executable(${testcase} $<TARGET_OBJECTS:catch_main> ${file})
     set_target_properties(${testcase} PROPERTIES
-        CXX_STANDARD 11
-        CXX_STANDARD_REQUIRED ON
         COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>"
         COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>"
     )
 
     target_compile_definitions(${testcase} PRIVATE CATCH_CONFIG_FAST_COMPILE)
+    target_compile_features(${testcase} PRIVATE cxx_std_11)
     target_include_directories(${testcase} PRIVATE "thirdparty/catch")
     target_include_directories(${testcase} PRIVATE "thirdparty/fifo_map")
     target_include_directories(${testcase} PRIVATE ${NLOHMANN_JSON_INCLUDE_BUILD_DIR})

From 896a9db461adbad68d025ef07396905ad6e90fb5 Mon Sep 17 00:00:00 2001
From: Niels Lohmann <mail@nlohmann.me>
Date: Wed, 28 Mar 2018 19:37:21 +0200
Subject: [PATCH 3/7] :hammer: improved code #1021

---
 include/nlohmann/detail/exceptions.hpp        |  1 -
 .../nlohmann/detail/output/binary_writer.hpp  | 86 +++++++++---------
 single_include/nlohmann/json.hpp              | 87 +++++++++----------
 test/src/unit-regression.cpp                  |  2 +-
 4 files changed, 79 insertions(+), 97 deletions(-)

diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp
index 53b38ec8..b73d7b1f 100644
--- a/include/nlohmann/detail/exceptions.hpp
+++ b/include/nlohmann/detail/exceptions.hpp
@@ -301,7 +301,6 @@ Exceptions have ids 5xx.
 name / id                      | example message | description
 ------------------------------ | --------------- | -------------------------
 json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed.
-json.exception.other_error.502 | type for number_float_t is not supported | The template type for a number is not supported for the binary serialization in CBOR, MessagePack or UBJSON.
 
 @sa @ref exception for the base class of the library exceptions
 @sa @ref parse_error for exceptions indicating a parse error
diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp
index 13968fed..71e5ec81 100644
--- a/include/nlohmann/detail/output/binary_writer.hpp
+++ b/include/nlohmann/detail/output/binary_writer.hpp
@@ -151,17 +151,7 @@ class binary_writer
 
             case value_t::number_float:
             {
-                switch (sizeof(typename BasicJsonType::number_float_t))
-                {
-                    case 4:  // Single-Precision Float
-                        oa->write_character(static_cast<CharType>(0xFA));
-                        break;
-                    case 8:  // Double-Precision Float
-                        oa->write_character(static_cast<CharType>(0xFB));
-                        break;
-                    default:
-                        JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
-                }
+                oa->write_character(get_cbor_float_prefix(j.m_value.number_float));
                 write_number(j.m_value.number_float);
                 break;
             }
@@ -421,17 +411,7 @@ class binary_writer
 
             case value_t::number_float:
             {
-                switch (sizeof(typename BasicJsonType::number_float_t))
-                {
-                    case 4:  // float 32
-                        oa->write_character(static_cast<CharType>(0xCA));
-                        break;
-                    case 8:  // float 64
-                        oa->write_character(static_cast<CharType>(0xCB));
-                        break;
-                    default:
-                        JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
-                }
+                oa->write_character(get_msgpack_float_prefix(j.m_value.number_float));
                 write_number(j.m_value.number_float);
                 break;
             }
@@ -608,7 +588,7 @@ class binary_writer
                 if (use_type and not j.m_value.array->empty())
                 {
                     assert(use_count);
-                    const char first_prefix = ubjson_prefix(j.front());
+                    const CharType first_prefix = ubjson_prefix(j.front());
                     const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
                                                          [this, first_prefix](const BasicJsonType & v)
                     {
@@ -619,7 +599,7 @@ class binary_writer
                     {
                         prefix_required = false;
                         oa->write_character(static_cast<CharType>('$'));
-                        oa->write_character(static_cast<CharType>(first_prefix));
+                        oa->write_character(first_prefix);
                     }
                 }
 
@@ -653,7 +633,7 @@ class binary_writer
                 if (use_type and not j.m_value.object->empty())
                 {
                     assert(use_count);
-                    const char first_prefix = ubjson_prefix(j.front());
+                    const CharType first_prefix = ubjson_prefix(j.front());
                     const bool same_prefix = std::all_of(j.begin(), j.end(),
                                                          [this, first_prefix](const BasicJsonType & v)
                     {
@@ -664,7 +644,7 @@ class binary_writer
                     {
                         prefix_required = false;
                         oa->write_character(static_cast<CharType>('$'));
-                        oa->write_character(static_cast<CharType>(first_prefix));
+                        oa->write_character(first_prefix);
                     }
                 }
 
@@ -732,17 +712,7 @@ class binary_writer
     {
         if (add_prefix)
         {
-            switch (sizeof(typename BasicJsonType::number_float_t))
-            {
-                case 4:  // float 32
-                    oa->write_character(static_cast<CharType>('d'));
-                    break;
-                case 8:  // float 64
-                    oa->write_character(static_cast<CharType>('D'));
-                    break;
-                default:
-                    JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
-            }
+            oa->write_character(get_ubjson_float_prefix(n));
         }
         write_number(n);
     }
@@ -863,7 +833,7 @@ class binary_writer
           write_number_with_ubjson_prefix. Therefore, we return 'L' for any
           value that does not fit the previous limits.
     */
-    char ubjson_prefix(const BasicJsonType& j) const noexcept
+    CharType ubjson_prefix(const BasicJsonType& j) const noexcept
     {
         switch (j.type())
         {
@@ -922,15 +892,7 @@ class binary_writer
             }
 
             case value_t::number_float:
-                switch (sizeof(typename BasicJsonType::number_float_t))
-                {
-                    case 4:  // float 32
-                        return 'd';
-                    case 8:  // float 64
-                        return 'D';
-                    default:
-                        JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
-                }
+                return get_ubjson_float_prefix(j.m_value.number_float);
 
             case value_t::string:
                 return 'S';
@@ -946,6 +908,36 @@ class binary_writer
         }
     }
 
+    static constexpr CharType get_cbor_float_prefix(float)
+    {
+        return static_cast<CharType>(0xFA);  // Single-Precision Float
+    }
+
+    static constexpr CharType get_cbor_float_prefix(double)
+    {
+        return static_cast<CharType>(0xFB);  // Double-Precision Float
+    }
+
+    static constexpr CharType get_msgpack_float_prefix(float)
+    {
+        return static_cast<CharType>(0xCA);  // float 32
+    }
+
+    static constexpr CharType get_msgpack_float_prefix(double)
+    {
+        return static_cast<CharType>(0xCB);  // float 64
+    }
+
+    static constexpr CharType get_ubjson_float_prefix(float)
+    {
+        return 'd';  // float 32
+    }
+
+    static constexpr CharType get_ubjson_float_prefix(double)
+    {
+        return 'D';  // float 64
+    }
+
   private:
     /// whether we can assume little endianess
     const bool is_little_endian = binary_reader<BasicJsonType>::little_endianess();
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index deeb9d5d..b7558aa5 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -794,7 +794,6 @@ Exceptions have ids 5xx.
 name / id                      | example message | description
 ------------------------------ | --------------- | -------------------------
 json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed.
-json.exception.other_error.502 | type for number_float_t is not supported | The template type for a number is not supported for the binary serialization in CBOR, MessagePack or UBJSON.
 
 @sa @ref exception for the base class of the library exceptions
 @sa @ref parse_error for exceptions indicating a parse error
@@ -6360,17 +6359,7 @@ class binary_writer
 
             case value_t::number_float:
             {
-                switch (sizeof(typename BasicJsonType::number_float_t))
-                {
-                    case 4:  // Single-Precision Float
-                        oa->write_character(static_cast<CharType>(0xFA));
-                        break;
-                    case 8:  // Double-Precision Float
-                        oa->write_character(static_cast<CharType>(0xFB));
-                        break;
-                    default:
-                        JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
-                }
+                oa->write_character(get_cbor_float_prefix(j.m_value.number_float));
                 write_number(j.m_value.number_float);
                 break;
             }
@@ -6630,17 +6619,7 @@ class binary_writer
 
             case value_t::number_float:
             {
-                switch (sizeof(typename BasicJsonType::number_float_t))
-                {
-                    case 4:  // float 32
-                        oa->write_character(static_cast<CharType>(0xCA));
-                        break;
-                    case 8:  // float 64
-                        oa->write_character(static_cast<CharType>(0xCB));
-                        break;
-                    default:
-                        JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
-                }
+                oa->write_character(get_msgpack_float_prefix(j.m_value.number_float));
                 write_number(j.m_value.number_float);
                 break;
             }
@@ -6817,7 +6796,7 @@ class binary_writer
                 if (use_type and not j.m_value.array->empty())
                 {
                     assert(use_count);
-                    const char first_prefix = ubjson_prefix(j.front());
+                    const CharType first_prefix = ubjson_prefix(j.front());
                     const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
                                                          [this, first_prefix](const BasicJsonType & v)
                     {
@@ -6828,7 +6807,7 @@ class binary_writer
                     {
                         prefix_required = false;
                         oa->write_character(static_cast<CharType>('$'));
-                        oa->write_character(static_cast<CharType>(first_prefix));
+                        oa->write_character(first_prefix);
                     }
                 }
 
@@ -6862,7 +6841,7 @@ class binary_writer
                 if (use_type and not j.m_value.object->empty())
                 {
                     assert(use_count);
-                    const char first_prefix = ubjson_prefix(j.front());
+                    const CharType first_prefix = ubjson_prefix(j.front());
                     const bool same_prefix = std::all_of(j.begin(), j.end(),
                                                          [this, first_prefix](const BasicJsonType & v)
                     {
@@ -6873,7 +6852,7 @@ class binary_writer
                     {
                         prefix_required = false;
                         oa->write_character(static_cast<CharType>('$'));
-                        oa->write_character(static_cast<CharType>(first_prefix));
+                        oa->write_character(first_prefix);
                     }
                 }
 
@@ -6941,17 +6920,7 @@ class binary_writer
     {
         if (add_prefix)
         {
-            switch (sizeof(typename BasicJsonType::number_float_t))
-            {
-                case 4:  // float 32
-                    oa->write_character(static_cast<CharType>('d'));
-                    break;
-                case 8:  // float 64
-                    oa->write_character(static_cast<CharType>('D'));
-                    break;
-                default:
-                    JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
-            }
+            oa->write_character(get_ubjson_float_prefix(n));
         }
         write_number(n);
     }
@@ -7072,7 +7041,7 @@ class binary_writer
           write_number_with_ubjson_prefix. Therefore, we return 'L' for any
           value that does not fit the previous limits.
     */
-    char ubjson_prefix(const BasicJsonType& j) const noexcept
+    CharType ubjson_prefix(const BasicJsonType& j) const noexcept
     {
         switch (j.type())
         {
@@ -7131,15 +7100,7 @@ class binary_writer
             }
 
             case value_t::number_float:
-                switch (sizeof(typename BasicJsonType::number_float_t))
-                {
-                    case 4:  // float 32
-                        return 'd';
-                    case 8:  // float 64
-                        return 'D';
-                    default:
-                        JSON_THROW(other_error::create(502, "type for number_float_t is not supported"));
-                }
+                return get_ubjson_float_prefix(j.m_value.number_float);
 
             case value_t::string:
                 return 'S';
@@ -7155,6 +7116,36 @@ class binary_writer
         }
     }
 
+    static constexpr CharType get_cbor_float_prefix(float)
+    {
+        return static_cast<CharType>(0xFA);  // Single-Precision Float
+    }
+
+    static constexpr CharType get_cbor_float_prefix(double)
+    {
+        return static_cast<CharType>(0xFB);  // Double-Precision Float
+    }
+
+    static constexpr CharType get_msgpack_float_prefix(float)
+    {
+        return static_cast<CharType>(0xCA);  // float 32
+    }
+
+    static constexpr CharType get_msgpack_float_prefix(double)
+    {
+        return static_cast<CharType>(0xCB);  // float 64
+    }
+
+    static constexpr CharType get_ubjson_float_prefix(float)
+    {
+        return 'd';  // float 32
+    }
+
+    static constexpr CharType get_ubjson_float_prefix(double)
+    {
+        return 'D';  // float 64
+    }
+
   private:
     /// whether we can assume little endianess
     const bool is_little_endian = binary_reader<BasicJsonType>::little_endianess();
diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp
index faa38a14..01e68957 100644
--- a/test/src/unit-regression.cpp
+++ b/test/src/unit-regression.cpp
@@ -118,7 +118,7 @@ struct nocopy
 // for #1021
 /////////////////////////////////////////////////////////////////////
 
-using float_json = nlohmann::basic_json<std::map, std::vector, std::string, bool, std::int32_t, std::uint32_t, float>;
+using float_json = nlohmann::basic_json<std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, float>;
 
 
 TEST_CASE("regression tests")

From 830c93fd09aa5c30e42bc6918ecc37d947fa9a24 Mon Sep 17 00:00:00 2001
From: Niels Lohmann <mail@nlohmann.me>
Date: Thu, 29 Mar 2018 17:07:55 +0200
Subject: [PATCH 4/7] :memo: fixed example for operator> #1029

---
 doc/examples/operator__greater.cpp    | 8 ++++----
 doc/examples/operator__greater.link   | 2 +-
 doc/examples/operator__greater.output | 8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/doc/examples/operator__greater.cpp b/doc/examples/operator__greater.cpp
index c632387c..65bb9c04 100644
--- a/doc/examples/operator__greater.cpp
+++ b/doc/examples/operator__greater.cpp
@@ -17,8 +17,8 @@ int main()
 
     // output values and comparisons
     std::cout << std::boolalpha;
-    std::cout << array_1 << " == " << array_2 << " " << (array_1 > array_2) << '\n';
-    std::cout << object_1 << " == " << object_2 << " " << (object_1 > object_2) << '\n';
-    std::cout << number_1 << " == " << number_2 << " " << (number_1 > number_2) << '\n';
-    std::cout << string_1 << " == " << string_2 << " " << (string_1 > string_2) << '\n';
+    std::cout << array_1 << " > " << array_2 << " " << (array_1 > array_2) << '\n';
+    std::cout << object_1 << " > " << object_2 << " " << (object_1 > object_2) << '\n';
+    std::cout << number_1 << " > " << number_2 << " " << (number_1 > number_2) << '\n';
+    std::cout << string_1 << " > " << string_2 << " " << (string_1 > string_2) << '\n';
 }
diff --git a/doc/examples/operator__greater.link b/doc/examples/operator__greater.link
index 3fc848ea..c59a48a1 100644
--- a/doc/examples/operator__greater.link
+++ b/doc/examples/operator__greater.link
@@ -1 +1 @@
-<a target="_blank" href="https://wandbox.org/permlink/yiz7oCHVpFHSALB1"><b>online</b></a>
\ No newline at end of file
+<a target="_blank" href="https://wandbox.org/permlink/ntF7DMzC85gbQKHu"><b>online</b></a>
\ No newline at end of file
diff --git a/doc/examples/operator__greater.output b/doc/examples/operator__greater.output
index 045847c3..910c48e3 100644
--- a/doc/examples/operator__greater.output
+++ b/doc/examples/operator__greater.output
@@ -1,4 +1,4 @@
-[1,2,3] == [1,2,4] false
-{"A":"a","B":"b"} == {"A":"a","B":"b"} false
-17 == 17.0000000000001 false
-"foo" == "bar" true
+[1,2,3] > [1,2,4] false
+{"A":"a","B":"b"} > {"A":"a","B":"b"} false
+17 > 17.0000000000001 false
+"foo" > "bar" true

From 4efa8cdb4c7ae03674da7a29e1d70ae067836643 Mon Sep 17 00:00:00 2001
From: Niels Lohmann <mail@nlohmann.me>
Date: Thu, 29 Mar 2018 17:19:21 +0200
Subject: [PATCH 5/7] :green_heart: fixed Valgrind options #1030

---
 test/CMakeLists.txt | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index e5f6dc55..9da2c80d 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -13,8 +13,7 @@ endif()
 if(JSON_Valgrind)
     find_program(CMAKE_MEMORYCHECK_COMMAND valgrind)
     message(STATUS "Executing test suite with Valgrind (${CMAKE_MEMORYCHECK_COMMAND})")
-    set(MEMORYCHECK_COMMAND_OPTIONS "--error-exitcode=1 --leak-check=full")
-    set(memcheck_command "${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}")
+    set(memcheck_command "${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS} --error-exitcode=1 --leak-check=full")
     separate_arguments(memcheck_command)
 endif()
 

From a35d414c390c2671f2f4a9aecbd84010377175de Mon Sep 17 00:00:00 2001
From: Kevin Tonon <nobigb@gmial.com>
Date: Tue, 3 Apr 2018 08:28:07 -0400
Subject: [PATCH 6/7] Update CMake to latest on Travis

---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index 8ce38cc8..68a16db5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -277,6 +277,7 @@ script:
      if [[ (-x $(which brew)) ]]; then
        brew update
        brew install cmake ninja
+       brew upgrade cmake
        cmake --version
      fi
 

From e439a1a9a78e95836a47e6189423400ee8a02cfd Mon Sep 17 00:00:00 2001
From: Axel Huebl <axel.huebl@plasma.ninja>
Date: Sat, 7 Apr 2018 13:15:44 +0200
Subject: [PATCH 7/7] CMake: 3.8+ is Sufficient

The current CMake scripts depend on CMake 3.8+.
This allows us to remove previous work-arounds.
---
 CMakeLists.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 958a129f..a490ab6b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,8 +53,8 @@ target_include_directories(
     $<INSTALL_INTERFACE:include>
 )
 
-## add debug view defintion file for msvc (natvis) [cmake <= 3.2.2 does not support export of source files]
-if (MSVC AND CMAKE_VERSION VERSION_GREATER "3.2.2")
+## add debug view defintion file for msvc (natvis)
+if (MSVC)
     set(NLOHMANN_ADD_NATVIS TRUE)
     set(NLOHMANN_NATVIS_FILE "nlohmann_json.natvis")
     target_sources(
@@ -64,7 +64,7 @@ if (MSVC AND CMAKE_VERSION VERSION_GREATER "3.2.2")
             $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${NLOHMANN_NATVIS_FILE}>  
     )
 endif()
-           
+
 ##
 ## TESTS
 ## create and configure the unit test target