Skip to content

Commit 8e206a1

Browse files
committed
Use C++11 type traits instead of Boost type traits
1 parent 6423f09 commit 8e206a1

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

src/portable_archive/portable_archive_includes.hpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@
9090

9191
#pragma once
9292

93-
// basic headers
94-
#include <boost/version.hpp>
95-
#include <boost/utility/enable_if.hpp>
96-
9793
// endian and fpclassify
9894
// disable std::fpclassify because it lacks the fp_traits::bits classes
9995
#define BOOST_MATH_DISABLE_STD_FPCLASSIFY
@@ -107,13 +103,8 @@ namespace fp = lslboost::math;
107103
namespace endian = lslboost::endian;
108104

109105
// generic type traits for numeric types
110-
#include <boost/type_traits/is_integral.hpp>
111-
#include <boost/type_traits/is_signed.hpp>
112-
#include <boost/type_traits/is_unsigned.hpp>
113-
#include <boost/type_traits/is_arithmetic.hpp>
114-
#include <boost/type_traits/is_floating_point.hpp>
106+
#include <type_traits>
115107

116-
#include "portable_archive_exception.hpp"
117108
#include <boost/cstdint.hpp>
118109

119110
#include "portable_archive_exception.hpp"

src/portable_archive/portable_iarchive.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ namespace eos {
147147
* to the original value by using load_little_endian.
148148
*/
149149
template <typename T>
150-
typename lslboost::enable_if<lslboost::is_integral<T> >::type
150+
typename std::enable_if<std::is_integral<T>::value >::type
151151
load(T & t, dummy<2> = 0)
152152
{
153153
// get the number of bytes in the stream
154154
if (signed char size = load_signed_char())
155155
{
156156
// check for negative value in unsigned type
157-
if (size < 0 && lslboost::is_unsigned<T>::value)
157+
if (size < 0 && std::is_unsigned<T>::value)
158158
throw portable_archive_exception();
159159

160160
// check that our type T is large enough
@@ -201,7 +201,7 @@ namespace eos {
201201
* small rounding off errors.
202202
*/
203203
template <typename T>
204-
typename lslboost::enable_if<lslboost::is_floating_point<T> >::type
204+
typename std::enable_if<std::is_floating_point<T>::value >::type
205205
load(T & t, dummy<3> = 0)
206206
{
207207
typedef typename fp::detail::fp_traits<T>::type traits;
@@ -234,7 +234,7 @@ namespace eos {
234234
// in boost 1.44 version_type was splitted into library_version_type and
235235
// item_version_type, plus a whole bunch of additional strong typedefs.
236236
template <typename T>
237-
typename lslboost::disable_if<lslboost::is_arithmetic<T> >::type
237+
typename std::enable_if<!std::is_arithmetic<T>::value >::type
238238
load(T& t, dummy<4> = 0)
239239
{
240240
// we provide a generic load routine for all types that feature

src/portable_archive/portable_oarchive.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ namespace eos {
132132
* and store non-zero bytes to the stream.
133133
*/
134134
template <typename T>
135-
typename lslboost::enable_if<lslboost::is_integral<T> >::type
135+
typename std::enable_if<std::is_integral<T>::value >::type
136136
save(const T & t, dummy<2> = 0)
137137
{
138138
if (T temp = t)
@@ -148,7 +148,7 @@ namespace eos {
148148

149149
// encode the sign bit into the size
150150
save_signed_char(t > 0 ? size : -size);
151-
BOOST_ASSERT(t > 0 || lslboost::is_signed<T>::value);
151+
BOOST_ASSERT(t > 0 || std::is_signed<T>::value);
152152

153153
// we choose to use little endian because this way we just
154154
// save the first size bytes to the stream and skip the rest
@@ -187,10 +187,10 @@ namespace eos {
187187
* small rounding off errors.
188188
*/
189189
template <typename T>
190-
typename lslboost::enable_if<lslboost::is_floating_point<T> >::type
190+
typename std::enable_if<std::is_floating_point<T>::value >::type
191191
save(const T & t, dummy<3> = 0)
192192
{
193-
typedef typename fp::detail::fp_traits<T>::type traits;
193+
using traits = typename fp::detail::fp_traits<T>::type;
194194

195195
// if the no_infnan flag is set we must throw here
196196
if (get_flags() & no_infnan && !fp::isfinite(t))
@@ -210,7 +210,7 @@ namespace eos {
210210
case FP_NAN: bits = traits::exponent | traits::significand; break;
211211
case FP_INFINITE: bits = traits::exponent | (t<0) * traits::sign; break;
212212
case FP_SUBNORMAL: assert(std::numeric_limits<T>::has_denorm); // pass
213-
case FP_ZERO: // note that floats can be ±0.0
213+
case FP_ZERO: // note that floats can be ±0.0
214214
case FP_NORMAL: traits::get_bits(t, bits); break;
215215
default: throw portable_archive_exception(t);
216216
}
@@ -221,7 +221,7 @@ namespace eos {
221221
// in lslboost 1.44 version_type was splitted into library_version_type and
222222
// item_version_type, plus a whole bunch of additional strong typedefs.
223223
template <typename T>
224-
typename lslboost::disable_if<lslboost::is_arithmetic<T> >::type
224+
typename std::enable_if<!std::is_arithmetic<T>::value >::type
225225
save(const T& t, dummy<4> = 0)
226226
{
227227
// we provide a generic save routine for all types that feature

0 commit comments

Comments
 (0)