Skip to content

Commit

Permalink
Remove uses of Boost.Array
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Dec 1, 2023
1 parent 34ae31a commit 888b749
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 72 deletions.
4 changes: 2 additions & 2 deletions include/boost/hash2/get_integral_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include <boost/hash2/byte_type.hpp>
#include <boost/hash2/detail/read.hpp>
#include <boost/array.hpp>
#include <boost/static_assert.hpp>
#include <array>
#include <type_traits>
#include <cstddef>

Expand All @@ -34,7 +34,7 @@ template<class T, class R>
}

template<class T, std::size_t N>
T get_integral_result( boost::array<byte_type, N> const & r )
T get_integral_result( std::array<byte_type, N> const & r )
{
BOOST_STATIC_ASSERT( N >= 8 );
return static_cast<T>( detail::read64le( &r[0] ) );
Expand Down
5 changes: 3 additions & 2 deletions include/boost/hash2/md5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

// Copyright 2017, 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// MD5 message digest algorithm, https://tools.ietf.org/html/rfc1321

Expand All @@ -11,10 +12,10 @@
#include <boost/hash2/detail/read.hpp>
#include <boost/hash2/detail/write.hpp>
#include <boost/hash2/detail/rot.hpp>
#include <boost/array.hpp>
#include <boost/cstdint.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <array>
#include <cstring>
#include <cstddef>

Expand Down Expand Up @@ -201,7 +202,7 @@ class md5_128

public:

typedef boost::array<byte_type, 16> result_type;
typedef std::array<byte_type, 16> result_type;
typedef boost::uint64_t size_type;

static const int block_size = 64;
Expand Down
5 changes: 3 additions & 2 deletions include/boost/hash2/murmur3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@

// Copyright 2017, 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// MurmurHash3, https://github.com/aappleby/smhasher/wiki/MurmurHash3

#include <boost/hash2/byte_type.hpp>
#include <boost/hash2/detail/read.hpp>
#include <boost/hash2/detail/write.hpp>
#include <boost/hash2/detail/rot.hpp>
#include <boost/array.hpp>
#include <boost/cstdint.hpp>
#include <boost/assert.hpp>
#include <array>
#include <cstring>
#include <cstddef>

Expand Down Expand Up @@ -266,7 +267,7 @@ class murmur3_128

public:

typedef boost::array<byte_type, 16> result_type;
typedef std::array<byte_type, 16> result_type;
typedef boost::uint64_t size_type;

explicit murmur3_128( boost::uint64_t seed = 0 ): m_( 0 ), n_( 0 )
Expand Down
5 changes: 3 additions & 2 deletions include/boost/hash2/sha1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

// Copyright 2017, 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// SHA1 message digest algorithm, https://tools.ietf.org/html/rfc3174

Expand All @@ -11,10 +12,10 @@
#include <boost/hash2/detail/read.hpp>
#include <boost/hash2/detail/write.hpp>
#include <boost/hash2/detail/rot.hpp>
#include <boost/array.hpp>
#include <boost/cstdint.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <array>
#include <cstring>
#include <cstddef>

Expand Down Expand Up @@ -198,7 +199,7 @@ class sha1_160

public:

typedef boost::array<byte_type, 20> result_type;
typedef std::array<byte_type, 20> result_type;
typedef boost::uint64_t size_type;

static const int block_size = 64;
Expand Down
5 changes: 3 additions & 2 deletions include/boost/hash2/spooky2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@

// Copyright 2017, 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// SpookyHash V2, http://burtleburtle.net/bob/hash/spooky.html

#include <boost/hash2/byte_type.hpp>
#include <boost/hash2/detail/read.hpp>
#include <boost/hash2/detail/write.hpp>
#include <boost/hash2/detail/rot.hpp>
#include <boost/array.hpp>
#include <boost/cstdint.hpp>
#include <boost/assert.hpp>
#include <array>
#include <utility>
#include <cstring>

Expand Down Expand Up @@ -236,7 +237,7 @@ class spooky2_128

public:

typedef boost::array<byte_type, 16> result_type;
typedef std::array<byte_type, 16> result_type;
typedef boost::uint64_t size_type;

explicit spooky2_128( boost::uint64_t seed1 = 0, boost::uint64_t seed2 = 0 ): m_( 0 ), n_( 0 )
Expand Down
4 changes: 2 additions & 2 deletions test/concept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <boost/hash2/byte_type.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/array.hpp>
#include <array>
#include <type_traits>
#include <limits>
#include <cstddef>
Expand All @@ -26,7 +26,7 @@ template<class R> struct is_valid_result:
{
};

template<std::size_t N> struct is_valid_result< boost::array<byte_type, N> >:
template<std::size_t N> struct is_valid_result< std::array<byte_type, N> >:
std::integral_constant<bool, N >= 8>
{
};
Expand Down
8 changes: 4 additions & 4 deletions test/get_integral_result.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

// Copyright 2017, 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

#include <boost/hash2/get_integral_result.hpp>
#include <boost/hash2/byte_type.hpp>
#include <boost/array.hpp>
#include <boost/cstdint.hpp>
#include <boost/core/lightweight_test.hpp>
#include <array>
#include <cstddef>

int main()
Expand Down Expand Up @@ -68,7 +68,7 @@ int main()
using boost::hash2::byte_type;

{
boost::array<byte_type, 8> a64 = {{ 0xEF, 0xCD, 0xAB, 0x89, 0x67, 0x45, 0x23, 0x01 }};
std::array<byte_type, 8> a64 = {{ 0xEF, 0xCD, 0xAB, 0x89, 0x67, 0x45, 0x23, 0x01 }};

BOOST_TEST_EQ( get_integral_result<boost::uint8_t>( a64 ), 0xEF );
BOOST_TEST_EQ( get_integral_result<boost::int8_t>( a64 ), -0x11 );
Expand All @@ -81,7 +81,7 @@ int main()
}

{
boost::array<byte_type, 8> b64 = {{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }};
std::array<byte_type, 8> b64 = {{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }};

BOOST_TEST_EQ( get_integral_result<boost::uint8_t>( b64 ), 0xFF );
BOOST_TEST_EQ( get_integral_result<boost::int8_t>( b64 ), -1 );
Expand Down
10 changes: 2 additions & 8 deletions test/hash_append.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@

// Copyright 2017 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// Endian-independent test

#include <boost/hash2/hash_append.hpp>
#include <boost/hash2/fnv1a.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/array.hpp>
#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
# include <array>
#endif
#include <array>

template<class H, class R> void test( R r )
{
Expand Down Expand Up @@ -57,8 +55,6 @@ template<class H, class R> void test( R r )
BOOST_TEST_EQ( h.result(), r );
}

#if !defined(BOOST_NO_CXX11_HDR_ARRAY)

{
std::array<unsigned char, 4> v = {{ 1, 2, 3, 4 }};

Expand All @@ -68,8 +64,6 @@ template<class H, class R> void test( R r )

BOOST_TEST_EQ( h.result(), r );
}

#endif
}

int main()
Expand Down
10 changes: 2 additions & 8 deletions test/hash_append_2.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@

// Copyright 2017 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// Endian-dependent test

#include <boost/hash2/hash_append.hpp>
#include <boost/hash2/fnv1a.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/array.hpp>
#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
# include <array>
#endif
#include <array>

template<class H, class R> void test( R r )
{
Expand Down Expand Up @@ -57,8 +55,6 @@ template<class H, class R> void test( R r )
BOOST_TEST_EQ( h.result(), r );
}

#if !defined(BOOST_NO_CXX11_HDR_ARRAY)

{
std::array<int, 4> v = {{ 1, 2, 3, 4 }};

Expand All @@ -68,8 +64,6 @@ template<class H, class R> void test( R r )

BOOST_TEST_EQ( h.result(), r );
}

#endif
}

int main()
Expand Down
18 changes: 3 additions & 15 deletions test/hash_append_4.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// Copyright 2017 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// Endian-independent test

Expand All @@ -9,12 +9,8 @@
#include <boost/core/lightweight_test.hpp>
#include <boost/array.hpp>
#include <utility>
#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
# include <array>
#endif
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)
# include <tuple>
#endif
#include <array>
#include <tuple>

template<class H, class R> void test( R r )
{
Expand Down Expand Up @@ -69,8 +65,6 @@ template<class H, class R> void test( R r )
BOOST_TEST_EQ( h.result(), r );
}

#if !defined(BOOST_NO_CXX11_HDR_ARRAY)

{
std::array<unsigned char, 2> v = { { 1, 2 } };

Expand All @@ -81,10 +75,6 @@ template<class H, class R> void test( R r )
BOOST_TEST_EQ( h.result(), r );
}

#endif

#if !defined(BOOST_NO_CXX11_HDR_TUPLE)

{
std::tuple<unsigned char, unsigned char> v( 1, 2 );

Expand All @@ -94,8 +84,6 @@ template<class H, class R> void test( R r )

BOOST_TEST_EQ( h.result(), r );
}

#endif
}

int main()
Expand Down
4 changes: 2 additions & 2 deletions test/hmac_md5.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// Copyright 2017, 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

#define _CRT_SECURE_NO_WARNINGS

Expand All @@ -13,7 +13,7 @@

using boost::hash2::byte_type;

template<std::size_t N> std::string to_string( boost::array<byte_type, N> const & v )
template<std::size_t N> std::string to_string( std::array<byte_type, N> const & v )
{
std::string r;

Expand Down
4 changes: 2 additions & 2 deletions test/hmac_sha1.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// Copyright 2017, 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

#define _CRT_SECURE_NO_WARNINGS

Expand All @@ -13,7 +13,7 @@

using boost::hash2::byte_type;

template<std::size_t N> std::string to_string( boost::array<byte_type, N> const & v )
template<std::size_t N> std::string to_string( std::array<byte_type, N> const & v )
{
std::string r;

Expand Down
18 changes: 3 additions & 15 deletions test/is_tuple_like.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@

// Copyright 2017 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

#include <boost/hash2/is_tuple_like.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/array.hpp>
#include <boost/config.hpp>
#include <utility>
#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
# include <array>
#endif
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)
# include <tuple>
#endif
#include <array>
#include <tuple>

struct X
{
Expand All @@ -37,8 +33,6 @@ int main()
BOOST_TEST_TRAIT_TRUE((is_tuple_like< std::pair<int, X> >));
BOOST_TEST_TRAIT_TRUE((is_tuple_like< std::pair<int, X> const >));

#if !defined(BOOST_NO_CXX11_HDR_ARRAY)

BOOST_TEST_TRAIT_TRUE((is_tuple_like< std::array<X, 0> >));
BOOST_TEST_TRAIT_TRUE((is_tuple_like< std::array<X, 0> const >));

Expand All @@ -51,10 +45,6 @@ int main()
BOOST_TEST_TRAIT_TRUE((is_tuple_like< std::array<X, 3> >));
BOOST_TEST_TRAIT_TRUE((is_tuple_like< std::array<X, 3> const >));

#endif

#if !defined(BOOST_NO_CXX11_HDR_TUPLE)

BOOST_TEST_TRAIT_TRUE((is_tuple_like< std::tuple<> >));
BOOST_TEST_TRAIT_TRUE((is_tuple_like< std::tuple<> const >));

Expand All @@ -67,8 +57,6 @@ int main()
BOOST_TEST_TRAIT_TRUE((is_tuple_like< std::tuple<X, X, X> >));
BOOST_TEST_TRAIT_TRUE((is_tuple_like< std::tuple<X, X, X> const >));

#endif

BOOST_TEST_TRAIT_TRUE((is_tuple_like< boost::array<X, 0> >));
BOOST_TEST_TRAIT_TRUE((is_tuple_like< boost::array<X, 0> const >));

Expand Down
Loading

0 comments on commit 888b749

Please sign in to comment.