1
0
forked from boostorg/core

Add boost/core/bit.hpp (bit_cast, rotl, rotr)

This commit is contained in:
Peter Dimov
2020-12-28 21:12:22 +02:00
parent 804c5b250d
commit 045487ba96
5 changed files with 388 additions and 0 deletions

29
test/bit_cast_test.cpp Normal file
View File

@@ -0,0 +1,29 @@
// Test for boost/core/bit.hpp
//
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/bit.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/cstdint.hpp>
#include <cstring>
int main()
{
{
float x = 0.89f;
boost::uint32_t y = boost::core::bit_cast<boost::uint32_t>( x );
BOOST_TEST( std::memcmp( &x, &y, sizeof(x) ) == 0 );
}
{
double x = 0.89;
boost::uint64_t y = boost::core::bit_cast<boost::uint64_t>( x );
BOOST_TEST( std::memcmp( &x, &y, sizeof(x) ) == 0 );
}
return boost::report_errors();
}