Skip to content

Commit 2805bc3

Browse files
committed
removed test dependency on lexical cast
1 parent a20c4d9 commit 2805bc3

8 files changed

Lines changed: 53 additions & 37 deletions

File tree

build/Jamfile.v2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ WSOURCES =
107107
xml_woarchive
108108
polymorphic_xml_wiarchive
109109
polymorphic_xml_woarchive
110+
codecvt_null
110111
;
111112

112113
lib boost_serialization

include/boost/archive/iterators/escape.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class escape :
8282
}
8383

8484
void increment(){
85-
if(m_bnext != NULL && ++m_bnext < m_bend){
85+
if(m_bnext != m_bend && ++m_bnext < m_bend){
8686
m_current_value = *m_bnext;
8787
return;
8888
}

include/boost/serialization/extended_type_info_no_rtti.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ class extended_type_info_no_rtti :
130130
void * construct(unsigned int count, ...) const BOOST_OVERRIDE {
131131
// count up the arguments
132132
std::va_list ap;
133-
va_start(ap, count);
134133
switch(count){
135134
case 0:
136135
return factory<typename boost::remove_const< T >::type, 0>(ap);

include/boost/serialization/extended_type_info_typeid.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ class extended_type_info_typeid :
113113
void * construct(unsigned int count, ...) const BOOST_OVERRIDE {
114114
// count up the arguments
115115
std::va_list ap;
116-
va_start(ap, count);
117116
switch(count){
118117
case 0:
119118
return factory<typename boost::remove_const< T >::type, 0>(ap);

include/boost/serialization/std_variant.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ inline void serialize(
176176

177177
// Specialization for std::monostate
178178
template<class Archive>
179-
void serialize(Archive &ar, std::monostate &, const unsigned int /*version*/)
179+
void serialize(Archive &, std::monostate &, const unsigned int /*version*/)
180180
{}
181181

182182
} // namespace serialization

include/boost/serialization/variant2.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#endif
88

99
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10-
// variant.hpp - non-intrusive serialization of variant types
10+
// variant2.hpp - non-intrusive serialization of variant types
1111
//
1212
// copyright (c) 2019 Samuel Debionne, ESRF
1313
//
@@ -22,8 +22,6 @@
2222

2323
#include <boost/serialization/throw_exception.hpp>
2424

25-
#include <variant>
26-
2725
#include <boost/archive/archive_exception.hpp>
2826

2927
#include <boost/mp11/list.hpp>

test/test_p_helper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ namespace std{
3333
#include <vector>
3434

3535
#include "test_tools.hpp"
36-
#include <boost/lexical_cast.hpp>
3736
#include <boost/serialization/split_free.hpp>
3837
#include <boost/serialization/vector.hpp>
3938
#include <boost/serialization/nvp.hpp>
@@ -121,7 +120,9 @@ int test_main(int /* argc */, char * /* argv */ [])
121120

122121
std::vector<my_string> v1;
123122
for(int i=0; i<1000; ++i){
124-
v1.push_back(my_string(boost::lexical_cast<std::string>(i % 100)));
123+
char sbuffer[10];
124+
std::snprintf(sbuffer, sizeof(sbuffer), "%i", i % 100);
125+
v1.push_back(my_string(sbuffer));
125126
}
126127

127128
// test using using polymorphic implementation.

test/test_variant.cpp

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -160,40 +160,58 @@ void test(Variant & v)
160160

161161
#include <boost/serialization/variant.hpp>
162162

163-
int test_main( int /* argc */, char* /* argv */[] ){
163+
#include <boost/variant/variant.hpp>
164164

165-
// boost::variant - compatible with C++03
166-
{
167-
boost::variant<bool, int, float, double, A, std::string> v;
168-
test(v);
169-
const A a;
170-
boost::variant<bool, int, float, double, const A *, std::string> v1 = & a;
171-
test_type(v1);
172-
}
165+
#include <cstdio>
166+
167+
int test_boost_variant(){
168+
std::cerr << "Testing boost_variant\n";
169+
boost::variant<bool, int, float, double, A, std::string> v;
170+
test(v);
171+
const A a;
172+
boost::variant<bool, int, float, double, const A *, std::string> v1 = & a;
173+
test_type(v1);
174+
return EXIT_SUCCESS;
175+
}
176+
177+
// boost::variant2/variant requires C++ 11
178+
#if BOOST_CXX_VERSION >= 201103L
179+
#include <boost/variant2/variant.hpp>
180+
181+
int test_boost_variant2(){
182+
std::cerr << "Testing boost_variant2\n";
183+
boost::variant2::variant<bool, int, float, double, A, std::string> v;
184+
test(v);
185+
const A a;
186+
boost::variant2::variant<bool, int, float, double, const A *, std::string> v1 = & a;
187+
test_type(v1);
188+
return EXIT_SUCCESS;
189+
}
190+
#endif
191+
192+
// std::variant reqires C++ 17 or more
193+
#ifndef BOOST_NO_CXX17_HDR_VARIANT
194+
#include <variant>
195+
int test_std_variant(){
196+
std::cerr << "Testing Std Variant\n";
197+
std::variant<bool, int, float, double, A, std::string> v;
198+
test(v);
199+
const A a;
200+
std::variant<bool, int, float, double, const A *, std::string> v1 = & a;
201+
test_type(v1);
202+
return EXIT_SUCCESS;
203+
}
204+
#endif
173205

174-
// boost::variant2/variant requires C++ 11
206+
int test_main( int /* argc */, char* /* argv */[] ){
207+
return test_boost_variant()
175208
#if BOOST_CXX_VERSION >= 201103L
176-
{
177-
boost::variant2::variant<bool, int, float, double, A, std::string> v;
178-
test(v);
179-
const A a;
180-
boost::variant2::variant<bool, int, float, double, const A *, std::string> v1 = & a;
181-
test_type(v1);
182-
}
209+
|| test_boost_variant2()
183210
#endif
184-
185-
// std::variant reqires C++ 17 or more
186211
#ifndef BOOST_NO_CXX17_HDR_VARIANT
187-
{
188-
std::variant<bool, int, float, double, A, std::string> v;
189-
test(v);
190-
const A a;
191-
std::variant<bool, int, float, double, const A *, std::string> v1 = & a;
192-
test_type(v1);
193-
}
212+
|| test_std_variant()
194213
#endif
195-
196-
return EXIT_SUCCESS;
214+
;
197215
}
198216

199217
// EOF

0 commit comments

Comments
 (0)