Skip to content

Commit ae63e84

Browse files
committed
Remove some boost usage in favour of C++11 features
1 parent c2ee228 commit ae63e84

File tree

6 files changed

+14
-17
lines changed

6 files changed

+14
-17
lines changed

src/parameters.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@
3838
#include <cstddef>
3939
#include <locale>
4040
#include <cassert>
41+
#include <type_traits>
4142
#include <boost/preprocessor.hpp>
42-
#include <boost/type_traits/is_integral.hpp>
43-
#include <boost/utility/enable_if.hpp>
4443
#include <clogs/visibility_pop.h>
4544

4645
#include <clogs/core.h>
@@ -83,7 +82,7 @@ CLOGS_LOCAL int readFields(sqlite3_stmt *stmt, int pos, std::vector<unsigned cha
8382

8483
/// @copydoc readFields(sqlite3_stmt *, int, std::string &)
8584
template<typename T>
86-
typename boost::enable_if<boost::is_integral<T>, int>::type
85+
typename std::enable_if<std::is_integral<T>::value, int>::type
8786
static inline readFields(sqlite3_stmt *stmt, int pos, T &value)
8887
{
8988
assert(pos >= 0 && pos < sqlite3_column_count(stmt));
@@ -130,7 +129,7 @@ static inline void fieldTypes(const std::vector<unsigned char> *, std::vector<co
130129

131130
/// @copydoc fieldTypes(const std::string *, std::vector<const char *> &)
132131
template<typename T>
133-
static inline typename boost::enable_if<boost::is_integral<T> >::type
132+
static inline typename std::enable_if<std::is_integral<T>::value>::type
134133
fieldTypes(const T *, std::vector<const char *> &out)
135134
{
136135
out.push_back("INT");

test/clogs_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <cppunit/TestResult.h>
3131
#include <cppunit/extensions/TestFactoryRegistry.h>
3232
#include <boost/program_options.hpp>
33-
#include <boost/foreach.hpp>
3433
#include <string>
3534
#include <stdexcept>
3635
#include <typeinfo>

test/test_common.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <cstddef>
3232
#include <stdexcept>
3333
#include <utility>
34-
#include <boost/smart_ptr/scoped_ptr.hpp>
34+
#include <memory>
3535
#include <clogs/core.h>
3636
#include <clogs/platform.h>
3737
#include "clogs_test.h"
@@ -86,7 +86,7 @@ bool TestCommon<T>::initialized(const T &obj)
8686
template<typename T>
8787
void TestCommon<T>::testMoveConstruct()
8888
{
89-
boost::scoped_ptr<T> s1((factory()));
89+
std::unique_ptr<T> s1((factory()));
9090
T s2(std::move(*s1));
9191
CPPUNIT_ASSERT(initialized(s2));
9292
CPPUNIT_ASSERT(!initialized(*s1));
@@ -95,7 +95,7 @@ void TestCommon<T>::testMoveConstruct()
9595
template<typename T>
9696
void TestCommon<T>::testMoveAssign()
9797
{
98-
boost::scoped_ptr<T> s1(factory());
98+
std::unique_ptr<T> s1(factory());
9999
T s2;
100100
s2 = std::move(*s1);
101101
CPPUNIT_ASSERT(initialized(s2));
@@ -106,7 +106,7 @@ void TestCommon<T>::testMoveAssign()
106106
template<typename T>
107107
void TestCommon<T>::testSwap()
108108
{
109-
boost::scoped_ptr<T> s1(factory());
109+
std::unique_ptr<T> s1(factory());
110110
T s2;
111111
clogs::swap(*s1, s2);
112112
CPPUNIT_ASSERT(initialized(s2));

test/test_radixsort.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "../src/clhpp11.h"
3030
#include <cppunit/extensions/TestFactoryRegistry.h>
3131
#include <cppunit/extensions/HelperMacros.h>
32-
#include <boost/scoped_ptr.hpp>
32+
#include <memory>
3333
#include <iostream>
3434
#include <sstream>
3535
#include <stdexcept>
@@ -50,7 +50,7 @@ using namespace std;
5050
* Recompiling the program for every test is slow, so we cheat slightly by keeping
5151
* one sorting object around across all tests that use UINT key/value pairs.
5252
*/
53-
static boost::scoped_ptr<clogs::detail::Radixsort> g_sort;
53+
static std::unique_ptr<clogs::detail::Radixsort> g_sort;
5454

5555
class TestRadixsort : public clogs::Test::TestCommon<clogs::Radixsort>
5656
{
@@ -269,7 +269,7 @@ static inline T roundUp(T a, T b)
269269
void TestRadixsort::setUp()
270270
{
271271
clogs::Test::TestFixture::setUp();
272-
if (g_sort == NULL)
272+
if (!g_sort)
273273
{
274274
clogs::detail::RadixsortProblem problem;
275275
problem.setKeyType(clogs::TYPE_UINT);

tools/options.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
#include "../src/clhpp11.h"
3030
#include <boost/program_options.hpp>
31-
#include <boost/foreach.hpp>
3231
#include <vector>
3332
#include "options.h"
3433

@@ -49,13 +48,13 @@ std::vector<cl::Device> findDevices(const boost::program_options::variables_map
4948

5049
vector<cl::Platform> platforms;
5150
cl::Platform::get(&platforms);
52-
BOOST_FOREACH(const cl::Platform &platform, platforms)
51+
for (const cl::Platform &platform : platforms)
5352
{
5453
vector<cl::Device> devices;
5554
cl_device_type type = CL_DEVICE_TYPE_ALL;
5655

5756
platform.getDevices(type, &devices);
58-
BOOST_FOREACH(const cl::Device &d, devices)
57+
for (const cl::Device &d : devices)
5958
{
6059
bool good = true;
6160
/* Match name if given */

wscript

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def configure(conf):
183183
if conf.options.cl_headers:
184184
conf.env.append_value('INCLUDES_OPENCL', [conf.options.cl_headers])
185185
conf.env.append_value('LIB_OPENCL', ['OpenCL'])
186-
conf.check_cxx(header_name='boost/foreach.hpp')
186+
conf.check_cxx(header_name='boost/any.hpp')
187187
conf.check_cxx(header_name='boost/program_options.hpp', use='PROGRAM_OPTIONS')
188188
conf.check_cxx(header_name='CL/cl.hpp', use='OPENCL')
189189
try:
@@ -205,7 +205,7 @@ def configure(conf):
205205
mandatory=False)
206206

207207
# Don't care about the defines, just insist the headers are there
208-
conf.undefine('HAVE_BOOST_FOREACH_HPP')
208+
conf.undefine('HAVE_BOOST_ANY_HPP')
209209
conf.undefine('HAVE_BOOST_PROGRAM_OPTIONS_HPP')
210210
conf.undefine('HAVE_CL_CL_HPP')
211211

0 commit comments

Comments
 (0)