Compare commits

...

41 Commits

Author SHA1 Message Date
d0af9f15ef bcbboost branch rebased on current release
[SVN r49389]
2008-10-19 14:43:01 +00:00
98a8b08afb Memory management fixes for is_any_of predicate merged from the trunk
[SVN r49172]
2008-10-07 21:59:57 +00:00
31777b28df Patches for Codegear C++ Builder 2009
[SVN r48981]
2008-09-27 08:59:20 +00:00
6d5e7b5a04 self assignment problem in is_any_ofF fixed
[SVN r48281]
2008-08-21 14:46:15 +00:00
760af1798b removed static constant FIXED_STORAGE_SIZE from is_any_of to
make the code compile on borland compilers



[SVN r48218]
2008-08-19 14:32:59 +00:00
1f5542b44c predicate test improvements
[SVN r48199]
2008-08-18 18:33:40 +00:00
baf3dd99e2 fox for allocation bug in is_any_ofF
[SVN r48198]
2008-08-18 18:32:51 +00:00
7299b29bf8 fixind the problems in is_any_ofF spotted by gcc
[SVN r46498]
2008-06-18 22:07:32 +00:00
539c170b9d aditional tests added
[SVN r46497]
2008-06-18 21:55:38 +00:00
c81ee948b7 is_any_ofF performance improvements
tabs removed



[SVN r46496]
2008-06-18 21:54:06 +00:00
ba5e4c30c6 fixed the rle example crash
[SVN r46463]
2008-06-17 21:58:58 +00:00
cd26ed816c patch from ticket #1152 applied
[SVN r46461]
2008-06-17 21:21:33 +00:00
4e15767bed simple_finder example fixed
[SVN r46460]
2008-06-17 21:13:25 +00:00
9fa2f90db4 begin() and end() calls made fully qualified
[SVN r46459]
2008-06-17 21:04:00 +00:00
35f317aeac unnecessary typedefs removed
[SVN r46458]
2008-06-17 20:31:41 +00:00
d0a03fdb4e Added missing include. This was already fixed on the 1.34 branch but never merged to the trunk.
[SVN r45857]
2008-05-28 08:32:12 +00:00
346f032be2 Quote href values - our tools don't support unquoted values.
[SVN r45283]
2008-05-11 13:49:20 +00:00
a389d768c4 Fix broken copyright urls. Fixes #1573.
[SVN r43422]
2008-02-27 18:51:14 +00:00
90fca39906 Point links to the pages that used to be in 'more' to the site.
[SVN r43210]
2008-02-10 15:02:17 +00:00
5b24f31486 merging changes from 1.34
[SVN r40698]
2007-11-02 21:00:08 +00:00
b25d6511b3 merging changes from 1.34
[SVN r40697]
2007-11-02 20:55:26 +00:00
1541a554f5 changed range_result_iterator to range_iterator
[SVN r40518]
2007-10-27 22:52:29 +00:00
d0bd40374e Merge from trunk
[SVN r39594]
2007-09-29 14:51:39 +00:00
7a97b3390e Added missing include.
[SVN r39586]
2007-09-28 07:19:29 +00:00
5dd2a2bc42 Merge from trunk
[SVN r39533]
2007-09-25 22:53:44 +00:00
6e5a7497ae Added missing include.
[SVN r39519]
2007-09-25 08:46:31 +00:00
fa8fcd2e61 Branch for CodeGear (Borland) specific fixes
[SVN r39356]
2007-09-17 20:28:43 +00:00
f0b8b60379 Update
[SVN r38522]
2007-08-08 19:24:04 +00:00
66019abb2f Update
[SVN r38521]
2007-08-08 19:23:38 +00:00
8758222006 Remove V1 Jamfiles
[SVN r38516]
2007-08-08 19:02:26 +00:00
4eef56761a find/split iterator tests added
[SVN r38126]
2007-07-01 22:24:29 +00:00
b94a3fbfba adapting to new range interface
[SVN r38125]
2007-07-01 22:23:55 +00:00
614cc2ebab adapting to new range interface
[SVN r38123]
2007-07-01 13:29:56 +00:00
869660ed14 adapted to the new range interface
[SVN r38122]
2007-07-01 13:12:57 +00:00
777f30780e Fix broken build of docs, it was missing a dependency to the doxygen docs.
[SVN r37466]
2007-04-17 17:19:25 +00:00
26aa37733b Fix a few more references to *.boosbook instead of *.xml generated files.
[SVN r37465]
2007-04-17 17:13:35 +00:00
f1e60579c2 documentation typo fixed
[SVN r36843]
2007-01-30 07:59:28 +00:00
389dd3c863 Add copyright, license
[SVN r35905]
2006-11-07 19:11:57 +00:00
f23f61ae9b License added to the xml doc files
[SVN r34895]
2006-08-16 07:17:49 +00:00
608112b112 boost guidelines (mainly from inspect tool: tabs, license reference text, etc.)
[SVN r34752]
2006-07-27 10:27:37 +00:00
b21b54dc4e Applying patch from Nicola Musatti
[SVN r33709]
2006-04-16 09:46:34 +00:00
2 changed files with 92 additions and 32 deletions

View File

@ -28,11 +28,7 @@ namespace boost {
// classification functors -----------------------------------------------//
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable:4512) //assignment operator could not be generated
#endif
// is_classified functor
// is_classified functor
struct is_classifiedF :
public predicate_facade<is_classifiedF>
{
@ -42,7 +38,6 @@ namespace boost {
// Constructor from a locale
is_classifiedF(std::ctype_base::mask Type, std::locale const & Loc = std::locale()) :
m_Type(Type), m_Locale(Loc) {}
// Operation
template<typename CharT>
bool operator()( CharT Ch ) const
@ -59,13 +54,10 @@ namespace boost {
#endif
private:
const std::ctype_base::mask m_Type;
const std::locale m_Locale;
std::ctype_base::mask m_Type;
std::locale m_Locale;
};
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
// is_any_of functor
/*
@ -77,9 +69,7 @@ namespace boost {
{
private:
// set cannot operate on const value-type
typedef typename remove_const<CharT>::type set_value_type;
// Size of the static storage (size of pointer*2)
static const ::std::size_t FIXED_STORAGE_SIZE = sizeof(set_value_type*)*2;
typedef typename ::boost::remove_const<CharT>::type set_value_type;
public:
// Boost.Lambda support
@ -96,7 +86,7 @@ namespace boost {
m_Size=Size;
set_value_type* Storage=0;
if(m_Size<=FIXED_STORAGE_SIZE)
if(use_fixed_storage(m_Size))
{
// Use fixed storage
Storage=&m_Storage.m_fixSet[0];
@ -121,7 +111,7 @@ namespace boost {
const set_value_type* SrcStorage=0;
set_value_type* DestStorage=0;
if(m_Size<=FIXED_STORAGE_SIZE)
if(use_fixed_storage(m_Size))
{
// Use fixed storage
DestStorage=&m_Storage.m_fixSet[0];
@ -142,36 +132,80 @@ namespace boost {
// Destructor
~is_any_ofF()
{
if(m_Size>FIXED_STORAGE_SIZE && m_Storage.m_dynSet!=0)
if(!use_fixed_storage(m_Size) && m_Storage.m_dynSet!=0)
{
delete m_Storage.m_dynSet;
delete [] m_Storage.m_dynSet;
}
}
// Assignment
is_any_ofF& operator=(const is_any_ofF& Other)
{
// Prepare storage
m_Storage.m_dynSet=0;
m_Size=Other.m_Size;
const set_value_type* SrcStorage=0;
set_value_type* DestStorage=0;
// Handle self assignment
if(this==&Other) return *this;
if(m_Size<=FIXED_STORAGE_SIZE)
// Prepare storage
const set_value_type* SrcStorage;
set_value_type* DestStorage;
if(use_fixed_storage(Other.m_Size))
{
// Use fixed storage
DestStorage=&m_Storage.m_fixSet[0];
SrcStorage=&Other.m_Storage.m_fixSet[0];
// Delete old storage if was present
if(!use_fixed_storage(m_Size) && m_Storage.m_dynSet!=0)
{
delete [] m_Storage.m_dynSet;
}
// Set new size
m_Size=Other.m_Size;
}
else
{
// Use dynamic storage
m_Storage.m_dynSet=new set_value_type[m_Size];
DestStorage=m_Storage.m_dynSet;
// Other uses dynamic storage
SrcStorage=Other.m_Storage.m_dynSet;
// Check what kind of storage are we using right now
if(use_fixed_storage(m_Size))
{
// Using fixed storage, allocate new
set_value_type* pTemp=new set_value_type[Other.m_Size];
DestStorage=pTemp;
m_Storage.m_dynSet=pTemp;
m_Size=Other.m_Size;
}
else
{
// Using dynamic storage, check if can reuse
if(m_Storage.m_dynSet!=0 && m_Size>=Other.m_Size && m_Size<Other.m_Size*2)
{
// Reuse the current storage
DestStorage=m_Storage.m_dynSet;
m_Size=Other.m_Size;
}
else
{
// Allocate the new one
set_value_type* pTemp=new set_value_type[Other.m_Size];
DestStorage=pTemp;
// Delete old storage if necessary
if(m_Storage.m_dynSet!=0)
{
delete [] m_Storage.m_dynSet;
}
// Store the new storage
m_Storage.m_dynSet=pTemp;
// Set new size
m_Size=Other.m_Size;
}
}
}
// Use fixed storage
// Copy the data
::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size);
return *this;
@ -182,12 +216,19 @@ namespace boost {
bool operator()( Char2T Ch ) const
{
const set_value_type* Storage=
(m_Size<=FIXED_STORAGE_SIZE)
(use_fixed_storage(m_Size))
? &m_Storage.m_fixSet[0]
: m_Storage.m_dynSet;
return ::std::binary_search(Storage, Storage+m_Size, Ch);
}
private:
// check if the size is eligible for fixed storage
static bool use_fixed_storage(std::size_t size)
{
return size<=sizeof(set_value_type*)*2;
}
private:
// storage
@ -195,7 +236,7 @@ namespace boost {
union
{
set_value_type* m_dynSet;
set_value_type m_fixSet[FIXED_STORAGE_SIZE];
set_value_type m_fixSet[sizeof(set_value_type*)*2];
}
m_Storage;

View File

@ -96,10 +96,29 @@ void predicate_test()
}
template<typename Pred, typename Input>
void test_pred(const Pred& pred, const Input& input, bool bYes)
{
// test assignment operator
Pred pred1=pred;
pred1=pred;
pred1=pred1;
if(bYes)
{
BOOST_CHECK( all( input, pred ) );
BOOST_CHECK( all( input, pred1 ) );
}
else
{
BOOST_CHECK( !all( input, pred ) );
BOOST_CHECK( !all( input, pred1 ) );
}
}
#define TEST_CLASS( Pred, YesInput, NoInput )\
{\
BOOST_CHECK( all( string(YesInput), Pred ) );\
BOOST_CHECK( !all( string(NoInput), Pred ) );\
test_pred(Pred, YesInput, true); \
test_pred(Pred, NoInput, false); \
}
void classification_test()