Compare commits

..

29 Commits

Author SHA1 Message Date
6eb48dd863 Merge pull request #112 from glywk/develop
Add is_blank() string functor classification
2025-04-13 13:46:42 -07:00
1395fe720c Merge pull request #123 from ahamez/develop
Fix documentation for  trim_all and trim_fill
2025-04-13 13:44:34 -07:00
35a55238a7 Fix documentation for trim_all and trim_fill 2025-01-13 11:20:30 +01:00
7f07838f8b Merge pull request #121 from grafikrobot/modular
Add support for modular build structure.
2024-09-03 11:59:17 -07:00
bbfcdf1322 Change Boost Test build refs to work with both old and modular test lib targets. 2024-08-08 21:45:19 -05:00
5c8e6ce9ba Add timer dependency for minmax examples. 2024-07-30 08:03:47 -05:00
0c0e84b112 Adjust self dependencies as inter-lib deps no longer apply globally. 2024-07-27 10:28:38 -05:00
81e46297b5 Move inter-lib dependencies to a project variable and into the build targets. 2024-07-23 22:34:22 -05:00
8189606c93 Update copyright dates. 2024-07-20 22:52:03 -05:00
c63c45a932 Bump B2 require to 5.2 2024-06-14 11:33:55 -05:00
1213b9fd1f Add requires-b2 check to top-level build file. 2024-05-05 09:00:00 -05:00
b3b2ff4d0c Remove relative references to boost-root in Jamfiles. 2024-04-13 16:18:29 -05:00
14922e71c0 Avoid global references to boost-root. 2024-04-13 11:15:55 -05:00
fcf95e504b Switch to library requirements instead of source. As source puts extra source in install targets. 2024-03-29 21:12:36 -05:00
6b1d2fc5ad Make the library modular usable. 2024-03-11 08:27:02 -05:00
dc14b69189 Add negative is_blank predicate tests 2023-07-27 23:15:48 +02:00
61fa3e461f Merge branch 'boostorg:develop' into develop 2023-07-27 01:17:32 +02:00
3401f0398f fix range-base gather algorithm 2023-07-27 01:04:04 +02:00
faac048d59 Merge pull request #116 from jiayuehua/develop
fix range-base gather algorithm
2023-06-14 09:23:41 -07:00
d1ecc8b0a8 fix range-base gather algorithm 2023-05-08 11:06:15 +08:00
1d9706feb7 Add is_blank classifier 2023-01-21 00:42:52 +01:00
3fe40eb999 Merge pull request #21 from MarcelRaad/fix_tests
Fix MSVC warnings in tests
2023-01-01 09:52:45 -08:00
e4d4a685da Fix MSVC warnings in tests
MSVC complains about narrowing conversions and unreferences parameters.
This makes all tests almost level 4 warning clean on MSVC 14.
2022-12-30 23:02:32 +01:00
7d8a063d35 Merge pull request #110 from Morwenn/patch-1
Fix links to The Old New Thing
2022-11-07 08:28:29 -08:00
0666c4ce35 Fix links to The Old New Thing
Blogs moved from https://blogs.msdn.microsoft.com to https://devblogs.microsoft.com
2022-11-07 16:44:05 +01:00
6f4d74c6bb Merge pull request #108 from denzor200/denzor200-patch-1
Add forgotten `inline` for `is_palindrome`
2022-10-12 07:39:41 -07:00
6d58f2b9d1 Update is_palindrome.hpp 2022-10-12 19:53:19 +06:00
6a5ca4e89c Merge pull request #107 from fanquake/use_core_enable_if
refactor: use core/enable_if over utility/enable_if
2022-08-30 21:47:33 -07:00
e8ba63c4ad refactor: use core/enable_if over utility/enable_if 2022-08-30 17:28:54 +01:00
32 changed files with 183 additions and 111 deletions

11
Jamfile
View File

@ -1,11 +0,0 @@
# Boost.Algorithm Library Jamfile
#
# Copyright (c) 2018 James E. King III
#
# Use, modification, and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# please order by name to ease maintenance
build-project example ;
build-project test ;

42
build.jam Normal file
View File

@ -0,0 +1,42 @@
# Copyright René Ferdinand Rivera Morell 2023-2024
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
require-b2 5.2 ;
constant boost_dependencies :
/boost/array//boost_array
/boost/assert//boost_assert
/boost/bind//boost_bind
/boost/concept_check//boost_concept_check
/boost/config//boost_config
/boost/core//boost_core
/boost/exception//boost_exception
/boost/function//boost_function
/boost/iterator//boost_iterator
/boost/mpl//boost_mpl
/boost/range//boost_range
/boost/regex//boost_regex
/boost/static_assert//boost_static_assert
/boost/throw_exception//boost_throw_exception
/boost/tuple//boost_tuple
/boost/type_traits//boost_type_traits
/boost/unordered//boost_unordered ;
project /boost/algorithm
: common-requirements
<include>include
;
explicit
[ alias boost_algorithm : : : : <library>$(boost_dependencies) ]
[ alias all : boost_algorithm test
example
minmax/example minmax/test
string/example string/test
]
;
call-if : boost-library algorithm
;

View File

@ -18,11 +18,11 @@ using boostbook ;
doxygen autodoc
:
[ glob ../../../boost/algorithm/*.hpp
../../../boost/algorithm/searching/*.hpp
../../../boost/algorithm/cxx11/*.hpp
../../../boost/algorithm/cxx14/*.hpp
../../../boost/algorithm/cxx17/*.hpp
[ glob ../include/boost/algorithm/*.hpp
../include/boost/algorithm/searching/*.hpp
../include/boost/algorithm/cxx11/*.hpp
../include/boost/algorithm/cxx14/*.hpp
../include/boost/algorithm/cxx17/*.hpp
]
:
<doxygen:param>"PREDEFINED=\"BOOST_ALGORITHM_DOXYGEN=1\""

View File

@ -16,12 +16,12 @@ The routine `apply_permutation` takes a item sequence and a order sequence. It r
The routine `apply_reverse_permutation` takes a item sequence and a order sequence. It will reshuffle item sequence according to order sequence. Every value in order sequence means where the item goes to. Order sequence needs to be exactly a permutation of the sequence [0, 1, ... , N], where N is the biggest index in the item sequence (zero-indexed).
Implementations are based on these articles:
https://blogs.msdn.microsoft.com/oldnewthing/20170102-00/?p=95095
https://blogs.msdn.microsoft.com/oldnewthing/20170103-00/?p=95105
https://blogs.msdn.microsoft.com/oldnewthing/20170104-00/?p=95115
https://blogs.msdn.microsoft.com/oldnewthing/20170109-00/?p=95145
https://blogs.msdn.microsoft.com/oldnewthing/20170110-00/?p=95155
https://blogs.msdn.microsoft.com/oldnewthing/20170111-00/?p=95165
https://devblogs.microsoft.com/oldnewthing/20170102-00/?p=95095
https://devblogs.microsoft.com/oldnewthing/20170103-00/?p=95105
https://devblogs.microsoft.com/oldnewthing/20170104-00/?p=95115
https://devblogs.microsoft.com/oldnewthing/20170109-00/?p=95145
https://devblogs.microsoft.com/oldnewthing/20170110-00/?p=95155
https://devblogs.microsoft.com/oldnewthing/20170111-00/?p=95165
The routines come in 2 forms; the first one takes two iterators to define the item range and one iterator to define the beginning of index range. The second form takes range to define the item sequence and range to define index sequence.

View File

@ -8,9 +8,9 @@
# See http://www.boost.org for updates, documentation, and revision history.
project /boost/algorithm/example
project
: requirements
<include>../../../
<library>/boost/algorithm//boost_algorithm
<optimization>speed
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
<toolset>msvc:<define>NOMINMAX

View File

@ -20,7 +20,7 @@
#include <functional> // for plus and multiplies
#include <boost/config.hpp>
#include <boost/utility/enable_if.hpp> // for boost::disable_if
#include <boost/core/enable_if.hpp> // for boost::disable_if
#include <boost/type_traits/is_integral.hpp>
namespace boost { namespace algorithm {

View File

@ -27,7 +27,7 @@
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/type_traits/type_identity.hpp> // for boost::type_identity
#include <boost/utility/enable_if.hpp> // for boost::disable_if
#include <boost/core/enable_if.hpp> // for boost::disable_if
namespace boost { namespace algorithm {

View File

@ -20,7 +20,7 @@
#include <boost/config.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace algorithm {

View File

@ -20,7 +20,7 @@
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/type_identity.hpp> // for boost::type_identity

View File

@ -1,4 +1,4 @@
/*
/*
Copyright 2008 Adobe Systems Incorporated
Distributed under the Boost Software License, Version 1.0. (See accompanying
@ -84,7 +84,7 @@ namespace boost { namespace algorithm {
template <
typename BidirectionalIterator, // models BidirectionalIterator
typename Pred> // models UnaryPredicate
std::pair<BidirectionalIterator, BidirectionalIterator> gather
std::pair<BidirectionalIterator, BidirectionalIterator> gather
( BidirectionalIterator first, BidirectionalIterator last, BidirectionalIterator pivot, Pred pred )
{
// The first call partitions everything up to (but not including) the pivot element,
@ -106,11 +106,11 @@ template <
typename BidirectionalRange, //
typename Pred> // Pred models UnaryPredicate
std::pair<
typename boost::range_iterator<const BidirectionalRange>::type,
typename boost::range_iterator<const BidirectionalRange>::type>
typename boost::range_iterator<BidirectionalRange>::type,
typename boost::range_iterator<BidirectionalRange>::type>
gather (
const BidirectionalRange &range,
typename boost::range_iterator<const BidirectionalRange>::type pivot,
BidirectionalRange &range,
typename boost::range_iterator<BidirectionalRange>::type pivot,
Pred pred )
{
return boost::algorithm::gather ( boost::begin ( range ), boost::end ( range ), pivot, pred );

View File

@ -30,7 +30,7 @@
#include <boost/exception/info.hpp>
#include <boost/throw_exception.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_integral.hpp>

View File

@ -113,7 +113,7 @@ bool is_palindrome(const R& range, Predicate p)
/// \note This function will return true for empty sequences and for palindromes.
/// For other sequences function will return false.
/// Complexity: O(N).
bool is_palindrome(const char* str)
inline bool is_palindrome(const char* str)
{
if(!str)
return true;

View File

@ -19,7 +19,7 @@
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/algorithm/searching/detail/bm_traits.hpp>

View File

@ -19,7 +19,7 @@
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/algorithm/searching/detail/bm_traits.hpp>

View File

@ -20,7 +20,7 @@
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/algorithm/searching/detail/debugging.hpp>

View File

@ -85,6 +85,22 @@ namespace boost {
return detail::is_classifiedF(std::ctype_base::alpha, Loc);
}
#ifndef BOOST_NO_CXX11
//! is_blank predicate
/*!
Construct the \c is_classified predicate for the \c ctype_base::blank category.
\param Loc A locale used for classification
\return An instance of the \c is_classified predicate
\since c++11
*/
inline detail::is_classifiedF
is_blank(const std::locale& Loc=std::locale())
{
return detail::is_classifiedF(std::ctype_base::blank, Loc);
}
#endif
//! is_cntrl predicate
/*!
Construct the \c is_classified predicate for the \c ctype_base::cntrl category.
@ -294,6 +310,9 @@ namespace boost {
// pull names to the boost namespace
using algorithm::is_classified;
using algorithm::is_space;
#ifndef BOOST_NO_CXX11
using algorithm::is_blank;
#endif
using algorithm::is_alnum;
using algorithm::is_alpha;
using algorithm::is_cntrl;

View File

@ -108,7 +108,6 @@ namespace boost {
\param Input An input sequence
\param Loc A locale used for 'space' classification
\return A trimmed copy of the input
*/
template<typename SequenceT>
inline void trim_all(SequenceT& Input, const std::locale& Loc =std::locale())
@ -191,7 +190,6 @@ namespace boost {
\param Input An input sequence
\param Fill A string used to fill the inner spaces
\param Loc A locale used for 'space' classification
\return A trimmed copy of the input
*/
template<typename SequenceT, typename RangeT>
inline void trim_fill(SequenceT& Input, const RangeT& Fill, const std::locale& Loc =std::locale())

View File

@ -7,6 +7,11 @@
# http://www.boost.org/LICENSE_1_0.txt)
#
project
: requirements
<library>/boost/algorithm//boost_algorithm
<library>/boost/timer//boost_timer ;
exe minmax_ex : minmax_ex.cpp ;
exe minmax_timer : minmax_timer.cpp ;

View File

@ -9,17 +9,19 @@
import testing ;
project : requirements <library>/boost/algorithm//boost_algorithm ;
alias unit_test_framework
: # sources
/boost//unit_test_framework
;
/boost/test//boost_unit_test_framework
;
{
test-suite algorithm/minmax
: [ run minmax_element_test.cpp unit_test_framework
: : : : minmax_element ]
[ run minmax_test.cpp unit_test_framework
: : : : minmax ]
: : : : minmax ]
;
}

View File

@ -10,40 +10,40 @@
import toolset ;
toolset.using doxygen ;
boostbook string_algo : string_algo.xml autodoc
boostbook string_algo : string_algo.xml autodoc
:
<xsl:param>boost.root=../../../../..
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
;
doxygen autodoc
:
[ glob ../../../../boost/algorithm/string.hpp ]
[ glob ../../../../boost/algorithm/string_regex.hpp ]
:
[ glob ../../include/boost/algorithm/string.hpp ]
[ glob ../../include/boost/algorithm/string_regex.hpp ]
[ glob ../../../../boost/algorithm/string/classification.hpp ]
[ glob ../../../../boost/algorithm/string/iterator_range.hpp ]
[ glob ../../../../boost/algorithm/string/sequence_traits.hpp ]
[ glob ../../../../boost/algorithm/string/std_containers_traits.hpp ]
[ glob ../../../../boost/algorithm/string/concept.hpp ]
[ glob ../../../../boost/algorithm/string/compare.hpp ]
[ glob ../../../../boost/algorithm/string/constants.hpp ]
[ glob ../../../../boost/algorithm/string/case_conv.hpp ]
[ glob ../../../../boost/algorithm/string/find.hpp ]
[ glob ../../../../boost/algorithm/string/finder.hpp ]
[ glob ../../../../boost/algorithm/string/find_iterator.hpp ]
[ glob ../../../../boost/algorithm/string/trim.hpp ]
[ glob ../../../../boost/algorithm/string/predicate.hpp ]
[ glob ../../../../boost/algorithm/string/split.hpp ]
[ glob ../../../../boost/algorithm/string/iter_find.hpp ]
[ glob ../../../../boost/algorithm/string/erase.hpp ]
[ glob ../../../../boost/algorithm/string/join.hpp ]
[ glob ../../../../boost/algorithm/string/replace.hpp ]
[ glob ../../../../boost/algorithm/string/find_format.hpp ]
[ glob ../../../../boost/algorithm/string/formatter.hpp ]
[ glob ../../../../boost/algorithm/string/regex.hpp ]
[ glob ../../../../boost/algorithm/string/regex_find_format.hpp ]
[ glob ../../../../boost/algorithm/string/trim_all.hpp ]
[ glob ../../include/boost/algorithm/string/classification.hpp ]
[ glob ../../include/boost/algorithm/string/iterator_range.hpp ]
[ glob ../../include/boost/algorithm/string/sequence_traits.hpp ]
[ glob ../../include/boost/algorithm/string/std_containers_traits.hpp ]
[ glob ../../include/boost/algorithm/string/concept.hpp ]
[ glob ../../include/boost/algorithm/string/compare.hpp ]
[ glob ../../include/boost/algorithm/string/constants.hpp ]
[ glob ../../include/boost/algorithm/string/case_conv.hpp ]
[ glob ../../include/boost/algorithm/string/find.hpp ]
[ glob ../../include/boost/algorithm/string/finder.hpp ]
[ glob ../../include/boost/algorithm/string/find_iterator.hpp ]
[ glob ../../include/boost/algorithm/string/trim.hpp ]
[ glob ../../include/boost/algorithm/string/predicate.hpp ]
[ glob ../../include/boost/algorithm/string/split.hpp ]
[ glob ../../include/boost/algorithm/string/iter_find.hpp ]
[ glob ../../include/boost/algorithm/string/erase.hpp ]
[ glob ../../include/boost/algorithm/string/join.hpp ]
[ glob ../../include/boost/algorithm/string/replace.hpp ]
[ glob ../../include/boost/algorithm/string/find_format.hpp ]
[ glob ../../include/boost/algorithm/string/formatter.hpp ]
[ glob ../../include/boost/algorithm/string/regex.hpp ]
[ glob ../../include/boost/algorithm/string/regex_find_format.hpp ]
[ glob ../../include/boost/algorithm/string/trim_all.hpp ]
:
<doxygen:param>HIDE_UNDOC_MEMBERS=YES
<doxygen:param>EXTRACT_PRIVATE=NO
@ -53,7 +53,7 @@ doxygen autodoc
<doxygen:param>SEARCH_INCLUDES=YES
<doxygen:param>PREDEFINED="BOOST_STRING_TYPENAME=typename \"BOOST_STATIC_CONSTANT(type,var)=static const type var;\""
;

View File

@ -667,6 +667,13 @@
<functionname>is_space()</functionname>
</entry>
</row>
<row>
<entry>is_blank</entry>
<entry>Recognize blanks</entry>
<entry>
<functionname>is_blank()</functionname>
</entry>
</row>
<row>
<entry>is_alnum</entry>
<entry>Recognize alphanumeric characters</entry>

View File

@ -7,6 +7,7 @@
#
# See http://www.boost.org for updates, documentation, and revision history.
project : requirements <library>/boost/algorithm//boost_algorithm ;
exe conv_example : conv_example.cpp ;
exe predicate_example : predicate_example.cpp ;

View File

@ -9,31 +9,33 @@
import testing ;
project : requirements <library>/boost/algorithm//boost_algorithm ;
alias unit_test_framework
: # sources
/boost//unit_test_framework
;
/boost/test//boost_unit_test_framework
;
test-suite algorithm/string
: [ run
: [ run
trim_test.cpp unit_test_framework
: :
:
: trim
]
[ run
[ run
conv_test.cpp unit_test_framework
: :
:
: conv
]
[ run
[ run
predicate_test.cpp unit_test_framework
: :
:
: predicate
]
[ run
[ run
find_test.cpp unit_test_framework
: :
:
@ -51,23 +53,23 @@ test-suite algorithm/string
:
: join
]
[ run
[ run
replace_test.cpp unit_test_framework
: :
:
: replace
]
[ run
[ run
regex_test.cpp unit_test_framework
../../../regex/build//boost_regex
: :
:
:
: regex
]
[ run
[ run
find_format_test.cpp unit_test_framework
: :
:
:
: find_format
]
;

View File

@ -138,7 +138,12 @@ void classification_test()
TEST_CLASS( is_any_of( string("abc") ), "aaabbcc", "aaxb" );
TEST_CLASS( is_any_of( "abc" ), "aaabbcc", "aaxb" );
TEST_CLASS( is_from_range( 'a', 'c' ), "aaabbcc", "aaxb" );
#ifndef BOOST_NO_CXX11
TEST_CLASS( is_blank(), " \t", "\t \n\r" );
TEST_CLASS( !is_blank(), "abc\n\v\f\r", "a x\t" );
#endif
TEST_CLASS( !is_classified(std::ctype_base::space), "...", "..\n\r\t " );
TEST_CLASS( ( !is_any_of("abc") && is_from_range('a','e') ) || is_space(), "d e", "abcde" );

View File

@ -9,9 +9,11 @@
import testing ;
project : requirements <library>/boost/algorithm//boost_algorithm ;
alias unit_test_framework
: # sources
/boost//unit_test_framework
/boost/test//boost_unit_test_framework
;
@ -85,7 +87,7 @@ alias unit_test_framework
# Is_partitioned_until tests
[ run is_partitioned_until_test.cpp unit_test_framework : : : : is_partitioned_until_test ]
# Apply_permutation tests
[ run apply_permutation_test.cpp unit_test_framework : : : : apply_permutation_test ]
# Find tests

View File

@ -28,8 +28,8 @@
namespace ba = boost::algorithm;
// namespace ba = boost;
BOOST_CXX14_CONSTEXPR bool is_true ( int v ) { return true; }
BOOST_CXX14_CONSTEXPR bool is_false ( int v ) { return false; }
BOOST_CXX14_CONSTEXPR bool is_true ( int ) { return true; }
BOOST_CXX14_CONSTEXPR bool is_false ( int ) { return false; }
BOOST_CXX14_CONSTEXPR bool is_even ( int v ) { return v % 2 == 0; }
BOOST_CXX14_CONSTEXPR bool is_odd ( int v ) { return v % 2 == 1; }
BOOST_CXX14_CONSTEXPR bool is_zero ( int v ) { return v == 0; }

View File

@ -25,7 +25,7 @@ void test_short_input1 () {
std::string s;
try { ba::unhex ( std::string ( "A" ), std::back_inserter(s)); }
catch ( const std::exception &ex ) { return; }
catch ( const std::exception & ) { return; }
BOOST_TEST_MESSAGE ( "Failed to catch std::exception in test_short_input1" );
BOOST_CHECK ( false );
}
@ -34,7 +34,7 @@ void test_short_input2 () {
std::string s;
try { ba::unhex ( std::string ( "A" ), std::back_inserter(s)); }
catch ( const ba::hex_decode_error &ex ) { return; }
catch ( const ba::hex_decode_error & ) { return; }
BOOST_TEST_MESSAGE ( "Failed to catch ba::hex_decode_error in test_short_input2" );
BOOST_CHECK ( false );
}
@ -43,7 +43,7 @@ void test_short_input3 () {
std::string s;
try { ba::unhex ( std::string ( "A" ), std::back_inserter(s)); }
catch ( const ba::not_enough_input &ex ) { return; }
catch ( const ba::not_enough_input & ) { return; }
BOOST_TEST_MESSAGE ( "Failed to catch ba::not_enough_input in test_short_input3" );
BOOST_CHECK ( false );
}
@ -53,8 +53,8 @@ void test_short_input4 () {
std::string s;
try { ba::unhex ( std::string ( "A" ), std::back_inserter(s)); }
catch ( const ba::non_hex_input &ex ) { BOOST_CHECK ( false ); }
catch ( const ba::not_enough_input &ex ) { return; }
catch ( const ba::non_hex_input & ) { BOOST_CHECK ( false ); }
catch ( const ba::not_enough_input & ) { return; }
catch ( ... ) { BOOST_CHECK ( false ); }
BOOST_CHECK ( false );
}
@ -64,8 +64,8 @@ void test_short_input5 () {
std::string s;
try { ba::unhex ( "A", std::back_inserter(s)); }
catch ( const ba::non_hex_input &ex ) { BOOST_CHECK ( false ); }
catch ( const ba::not_enough_input &ex ) { return; }
catch ( const ba::non_hex_input & ) { BOOST_CHECK ( false ); }
catch ( const ba::not_enough_input & ) { return; }
catch ( ... ) { BOOST_CHECK ( false ); }
BOOST_CHECK ( false );
}
@ -125,8 +125,8 @@ void test_nonhex_input4 () {
std::string s;
try { ba::unhex ( "P1234FA1234", std::back_inserter(s)); }
catch ( const ba::not_enough_input &ex ) { BOOST_CHECK ( false ); }
catch ( const ba::non_hex_input &ex ) { return; }
catch ( const ba::not_enough_input & ) { BOOST_CHECK ( false ); }
catch ( const ba::non_hex_input & ) { return; }
catch ( ... ) { BOOST_CHECK ( false ); }
BOOST_CHECK ( false );
}

View File

@ -112,7 +112,7 @@ void test_sequence1 () {
std::vector<int> v, v1;
v.clear ();
for ( std::size_t i = 5; i < 15; ++i )
for ( int i = 5; i < 15; ++i )
v.push_back ( i );
v1 = v;
BOOST_CHECK ( ba::is_permutation ( v.begin (), v.end (), v.begin ())); // better be a permutation of itself!

View File

@ -32,7 +32,7 @@ namespace {
// Check using iterators
template<typename Container>
void check_one_iter ( const Container &haystack, const std::string &needle, int expected ) {
void check_one_iter ( const Container &haystack, const std::string &needle, std::ptrdiff_t expected ) {
typedef typename Container::const_iterator iter_type;
typedef typename std::pair<iter_type, iter_type> ret_type;
typedef std::string::const_iterator pattern_type;
@ -53,7 +53,7 @@ namespace {
// iter_type it1r = ret1r.first;
// iter_type it2 = ret2.first;
// iter_type it3 = ret3.first;
const int dist = ret1.first == hEnd ? -1 : std::distance ( hBeg, ret1.first );
const std::ptrdiff_t dist = ret1.first == hEnd ? -1 : std::distance ( hBeg, ret1.first );
std::cout << "(Iterators) Pattern is " << needle.length () << ", haysstack is " << haystack.length () << " chars long; " << std::endl;
try {
@ -97,7 +97,7 @@ namespace {
// Check using pointers
// We're assuming that the container implements contiguous storage here.
template<typename Container>
void check_one_pointer ( const Container &haystack, const std::string &needle, int expected ) {
void check_one_pointer ( const Container &haystack, const std::string &needle, std::ptrdiff_t expected ) {
typedef const typename Container::value_type *ptr_type;
typedef typename std::pair<ptr_type, ptr_type> ret_type;
@ -110,7 +110,7 @@ namespace {
ret_type ret1 = ba::boyer_moore_search (hBeg, hEnd, nBeg, nEnd);
ret_type ret2 = ba::boyer_moore_horspool_search (hBeg, hEnd, nBeg, nEnd);
ret_type ret3 = ba::knuth_morris_pratt_search (hBeg, hEnd, nBeg, nEnd);
const int dist = ret1.first == hEnd ? -1 : std::distance ( hBeg, ret1.first );
const std::ptrdiff_t dist = ret1.first == hEnd ? -1 : std::distance ( hBeg, ret1.first );
std::cout << "(Pointers) Pattern is " << needle.length () << ", haysstack is " << haystack.length () << " chars long; " << std::endl;
try {
@ -147,7 +147,7 @@ namespace {
// Check using objects
template<typename Container>
void check_one_object ( const Container &haystack, const std::string &needle, int expected ) {
void check_one_object ( const Container &haystack, const std::string &needle, std::ptrdiff_t expected ) {
typedef typename Container::const_iterator iter_type;
typedef typename std::pair<iter_type, iter_type> ret_type;
typedef std::string::const_iterator pattern_type;
@ -169,7 +169,7 @@ namespace {
ret_type retr1r = bm_r (haystack);
ret_type ret2 = bmh (hBeg, hEnd);
ret_type ret3 = kmp (hBeg, hEnd);
const int dist = ret1.first == hEnd ? -1 : std::distance ( hBeg, ret1.first );
const std::ptrdiff_t dist = ret1.first == hEnd ? -1 : std::distance ( hBeg, ret1.first );
std::cout << "(Objects) Pattern is " << needle.length () << ", haysstack is " << haystack.length () << " chars long; " << std::endl;
try {
@ -224,7 +224,7 @@ namespace {
template<typename Container>
void check_one ( const Container &haystack, const std::string &needle, int expected ) {
void check_one ( const Container &haystack, const std::string &needle, std::ptrdiff_t expected ) {
check_one_iter ( haystack, needle, expected );
check_one_pointer ( haystack, needle, expected );
check_one_object ( haystack, needle, expected );

View File

@ -85,7 +85,7 @@ namespace {
std::cout << std::endl;
}
void check_one ( const vec &haystack, const vec &needle, int expected ) {
void check_one ( const vec &haystack, const vec &needle, std::ptrdiff_t expected ) {
std::size_t i;
std::clock_t sTime;
unsigned long stdDiff;
@ -147,7 +147,7 @@ BOOST_AUTO_TEST_CASE( test_main )
std::cout << "---- Middle -----" << std::endl;
check_one ( c1, p1f, -2 ); // Don't know answer
std::cout << "------ End ------" << std::endl;
check_one ( c1, p1e, c1.size() - p1e.size ());
check_one ( c1, p1e, static_cast<std::ptrdiff_t>(c1.size() - p1e.size ()));
std::cout << "--- Not found ---" << std::endl;
check_one ( c1, p1n, -1 ); // Not found
}

View File

@ -85,7 +85,7 @@ namespace {
std::cout << std::endl;
}
void check_one ( const vec &haystack, const vec &needle, int expected ) {
void check_one ( const vec &haystack, const vec &needle, std::ptrdiff_t expected ) {
std::size_t i;
std::clock_t sTime;
unsigned long stdDiff;
@ -147,7 +147,7 @@ BOOST_AUTO_TEST_CASE( test_main )
std::cout << "---- Middle -----" << std::endl;
check_one ( c1, p1f, -2 ); // Don't know answer
std::cout << "------ End ------" << std::endl;
check_one ( c1, p1e, c1.size() - p1e.size ());
check_one ( c1, p1e, static_cast<std::ptrdiff_t>(c1.size() - p1e.size ()));
std::cout << "--- Not found ---" << std::endl;
check_one ( c1, p1n, -1 ); // Not found
}

View File

@ -62,7 +62,7 @@ namespace {
return retVal;
}
void check_one ( const vec &haystack, const vec &needle, int expected ) {
void check_one ( const vec &haystack, const vec &needle, std::ptrdiff_t expected ) {
std::pair<vec::const_iterator, vec::const_iterator> res;
std::pair<vec::const_iterator, vec::const_iterator> exp; // the expected result
@ -117,7 +117,7 @@ BOOST_AUTO_TEST_CASE( test_main )
std::cout << "---- Middle -----" << std::endl;
check_one ( c1, p1f, -2 ); // Don't know answer
std::cout << "------ End ------" << std::endl;
check_one ( c1, p1e, c1.size() - p1e.size ());
check_one ( c1, p1e, static_cast<std::ptrdiff_t>(c1.size() - p1e.size ()));
std::cout << "--- Not found ---" << std::endl;
check_one ( c1, p1n, -1 ); // Not found
}