Skip to content

Testfailures if boost::uint_t<XX>::fast isn't the same as boost::uint_t<XX>::least #12

Description

@MBalszun

I don't know what the exact reason is, but if you apply the following patch to Boost.Integer, crc_test and crc_test2 fail:

--- include/boost/integer.hpp
+++ include/boost/integer.hpp
@@ -48,6 +48,13 @@ namespace boost
	  typedef fast     type;
   }; // imps may specialize

+  template<>
+  struct int_fast_t<unsigned short>
+  {
+      typedef unsigned int fast;
+      typedef unsigned int type;
+  };
+
   namespace detail{

   //  convert category to type

Best I can tell, this is the correct way to tell boost that it is faster to perform operations on ints than on shorts on a particular platform, even if you only need 16 bit.

Background: I was trying to convert Boost.CRC int a standalone version without any boost dependencies using the std::uint_fast_XX_t / _least_XX_t type alieases instead of the boost::uint_t<XX>::fast/least ones.
At least on msvc x64, std::uint_fast16_t is unsigned int, not unsigned short. After some investigation I could reproduce this even without touching boost crc but only changing boost::uint_t<16> in Boost.Integer as above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions