replace tabs with 4 spaces

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@680 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2006-06-19 12:39:09 +00:00
parent 963152efd4
commit 30f4e933c1
14 changed files with 298 additions and 283 deletions

View file

@ -35,21 +35,21 @@ namespace Loki
/// Is the default smart pointer of Pimpl. /// Is the default smart pointer of Pimpl.
////////////////////////////////////////// //////////////////////////////////////////
template<class T> template<class T>
struct ConstPropPtr struct ConstPropPtr
{ {
explicit ConstPropPtr(T* p) : ptr_(p) {} explicit ConstPropPtr(T* p) : ptr_(p) {}
~ConstPropPtr() { delete ptr_; ptr_ = 0; } ~ConstPropPtr() { delete ptr_; ptr_ = 0; }
T* operator->() { return ptr_; } T* operator->() { return ptr_; }
T& operator*() { return *ptr_; } T& operator*() { return *ptr_; }
const T* operator->() const { return ptr_; } const T* operator->() const { return ptr_; }
const T& operator*() const { return *ptr_; } const T& operator*() const { return *ptr_; }
private: private:
ConstPropPtr(); ConstPropPtr();
ConstPropPtr(const ConstPropPtr&); ConstPropPtr(const ConstPropPtr&);
ConstPropPtr& operator=(const ConstPropPtr&); ConstPropPtr& operator=(const ConstPropPtr&);
T* ptr_; T* ptr_;
}; };
@ -66,18 +66,18 @@ namespace Loki
/// see test/Pimpl /// see test/Pimpl
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template template
< <
class T, class T,
typename Pointer = ConstPropPtr<T> typename Pointer = ConstPropPtr<T>
> >
class Pimpl class Pimpl
{ {
public: public:
typedef T Impl; typedef T Impl;
Pimpl() : ptr_(new T) Pimpl() : ptr_(new T)
{} {}
~Pimpl() ~Pimpl()
@ -89,11 +89,11 @@ namespace Loki
// destructor of the class hosting the pimpl: // destructor of the class hosting the pimpl:
// - implement the destructor of the class // - implement the destructor of the class
// - don't inline the destructor // - don't inline the destructor
typedef char T_must_be_defined[sizeof(T) ? 1 : -1 ]; typedef char T_must_be_defined[sizeof(T) ? 1 : -1 ];
} }
T* operator->() T* operator->()
{ {
return ptr_.operator->(); return ptr_.operator->();
} }
@ -113,26 +113,26 @@ namespace Loki
return ptr_.operator*(); return ptr_.operator*();
} }
Pointer& wrapped() Pointer& wrapped()
{ {
return ptr_; return ptr_;
} }
const Pointer& wrapped() const const Pointer& wrapped() const
{ {
return ptr_; return ptr_;
} }
private: private:
Pimpl(const Pimpl&); Pimpl(const Pimpl&);
Pimpl& operator=(const Pimpl&); Pimpl& operator=(const Pimpl&);
Pointer ptr_; Pointer ptr_;
}; };
template<class T, typename Pointer = ConstPropPtr<T> > template<class T, typename Pointer = ConstPropPtr<T> >
struct PimplOwner struct PimplOwner
{ {
Pimpl<T,Pointer> LOKI_INHERITED_PIMPL_NAME; Pimpl<T,Pointer> LOKI_INHERITED_PIMPL_NAME;
@ -163,7 +163,7 @@ namespace Loki
template<class T, template<class> class Ptr = ConstPropPtr> template<class T, template<class> class Ptr = ConstPropPtr>
struct PimplT struct PimplT
{ {
typedef T Impl; typedef T Impl;
// declare pimpl // declare pimpl
typedef Pimpl<ImplT<T>, Ptr<ImplT<T> > > Type; typedef Pimpl<ImplT<T>, Ptr<ImplT<T> > > Type;
@ -173,20 +173,20 @@ namespace Loki
}; };
template<class T, class UsedPimpl = typename PimplT<T>::Type > template<class T, class UsedPimpl = typename PimplT<T>::Type >
struct RimplT struct RimplT
{ {
typedef typename UsedPimpl::Impl & Type; typedef typename UsedPimpl::Impl & Type;
class Owner class Owner
{ {
UsedPimpl pimpl; UsedPimpl pimpl;
public: public:
Owner() : LOKI_INHERITED_RIMPL_NAME(*pimpl) Owner() : LOKI_INHERITED_RIMPL_NAME(*pimpl)
{} {}
Type LOKI_INHERITED_RIMPL_NAME; Type LOKI_INHERITED_RIMPL_NAME;
}; };
}; };
@ -196,6 +196,9 @@ namespace Loki
#endif #endif
// $Log$ // $Log$
// Revision 1.21 2006/06/19 12:39:08 syntheticpp
// replace tabs with 4 spaces
//
// Revision 1.20 2006/03/27 15:33:24 syntheticpp // Revision 1.20 2006/03/27 15:33:24 syntheticpp
// fix spelling // fix spelling
// //

View file

@ -32,38 +32,38 @@ namespace Loki
/// \ingroup RegisterGroup /// \ingroup RegisterGroup
/// Must be specialized be the user /// Must be specialized be the user
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class t> bool RegisterFunction(); template<class t> bool RegisterFunction();
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// \ingroup RegisterGroup /// \ingroup RegisterGroup
/// Must be specialized be the user /// Must be specialized be the user
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class t> bool UnRegisterFunction(); template<class t> bool UnRegisterFunction();
namespace Private namespace Private
{ {
template<class T> template<class T>
struct RegisterOnCreate struct RegisterOnCreate
{ {
RegisterOnCreate() { RegisterFunction<T>(); } RegisterOnCreate() { RegisterFunction<T>(); }
}; };
template<class T> template<class T>
struct UnRegisterOnDelete struct UnRegisterOnDelete
{ {
~UnRegisterOnDelete() { UnRegisterFunction<T>(); } ~UnRegisterOnDelete() { UnRegisterFunction<T>(); }
}; };
template<class T> template<class T>
struct RegisterOnCreateElement struct RegisterOnCreateElement
{ {
RegisterOnCreate<T> registerObj; RegisterOnCreate<T> registerObj;
}; };
template<class T> template<class T>
struct UnRegisterOnDeleteElement struct UnRegisterOnDeleteElement
{ {
UnRegisterOnDelete<T> unregisterObj; UnRegisterOnDelete<T> unregisterObj;
}; };
} }
@ -77,8 +77,8 @@ namespace Loki
/// see test/Register /// see test/Register
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<typename ElementList> template<typename ElementList>
struct RegisterOnCreateSet struct RegisterOnCreateSet
: GenScatterHierarchy<ElementList, Private::RegisterOnCreateElement> : GenScatterHierarchy<ElementList, Private::RegisterOnCreateElement>
{}; {};
@ -91,8 +91,8 @@ namespace Loki
/// \par Usage /// \par Usage
/// see test/Register /// see test/Register
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<typename ElementList> template<typename ElementList>
struct UnRegisterOnDeleteSet struct UnRegisterOnDeleteSet
: GenScatterHierarchy<ElementList, Private::UnRegisterOnDeleteElement> : GenScatterHierarchy<ElementList, Private::UnRegisterOnDeleteElement>
{}; {};
@ -109,11 +109,11 @@ namespace Loki
#define LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST ) \ #define LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST ) \
\ \
struct Loki_##CLASS##LIST_OK{typedef int class_##CLASS##_is_not_in_##LIST;};\ struct Loki_##CLASS##LIST_OK{typedef int class_##CLASS##_is_not_in_##LIST;};\
typedef Loki::Select<Loki::TL::IndexOf<LIST, CLASS>::value == -1, \ typedef Loki::Select<Loki::TL::IndexOf<LIST, CLASS>::value == -1, \
CLASS,Loki_##CLASS##LIST_OK >::Result IsInList##CLASS##LIST; \ CLASS,Loki_##CLASS##LIST_OK >::Result IsInList##CLASS##LIST; \
typedef IsInList##CLASS##LIST::class_##CLASS##_is_not_in_##LIST \ typedef IsInList##CLASS##LIST::class_##CLASS##_is_not_in_##LIST \
isInListTest##CLASS##LIST; isInListTest##CLASS##LIST;
} // namespace Loki } // namespace Loki

View file

@ -50,11 +50,11 @@ namespace Loki
// Crude writing method: writes straight to the file, unbuffered // Crude writing method: writes straight to the file, unbuffered
// Must be combined with a buffer to work properly (and efficiently) // Must be combined with a buffer to work properly (and efficiently)
LOKI_EXPORT LOKI_EXPORT
void write(std::FILE* f, const char* from, const char* to); void write(std::FILE* f, const char* from, const char* to);
// Write to a string // Write to a string
LOKI_EXPORT LOKI_EXPORT
void write(std::string& s, const char* from, const char* to); void write(std::string& s, const char* from, const char* to);
// Write to a fixed-size buffer // Write to a fixed-size buffer
@ -532,22 +532,22 @@ namespace Loki
LOKI_SAFEFORMAT_SIGNED_LONG result_; LOKI_SAFEFORMAT_SIGNED_LONG result_;
}; };
LOKI_EXPORT LOKI_EXPORT
PrintfState<std::FILE*, char> Printf(const char* format); PrintfState<std::FILE*, char> Printf(const char* format);
LOKI_EXPORT LOKI_EXPORT
PrintfState<std::FILE*, char> Printf(const std::string format); PrintfState<std::FILE*, char> Printf(const std::string format);
LOKI_EXPORT LOKI_EXPORT
PrintfState<std::FILE*, char> FPrintf(FILE* f, const char* format); PrintfState<std::FILE*, char> FPrintf(FILE* f, const char* format);
LOKI_EXPORT LOKI_EXPORT
PrintfState<std::FILE*, char> FPrintf(FILE* f, const std::string& format); PrintfState<std::FILE*, char> FPrintf(FILE* f, const std::string& format);
LOKI_EXPORT LOKI_EXPORT
PrintfState<std::string&, char> SPrintf(std::string& s, const char* format); PrintfState<std::string&, char> SPrintf(std::string& s, const char* format);
LOKI_EXPORT LOKI_EXPORT
PrintfState<std::string&, char> SPrintf(std::string& s, const std::string& format); PrintfState<std::string&, char> SPrintf(std::string& s, const std::string& format);
template <class T, class Char> template <class T, class Char>
@ -573,6 +573,9 @@ namespace Loki
#endif //SAFEFORMAT_H_ #endif //SAFEFORMAT_H_
// $Log$ // $Log$
// Revision 1.25 2006/06/19 12:39:08 syntheticpp
// replace tabs with 4 spaces
//
// Revision 1.24 2006/02/28 11:13:20 syntheticpp // Revision 1.24 2006/02/28 11:13:20 syntheticpp
// add export specifier // add export specifier
// //

View file

@ -872,12 +872,12 @@ namespace Loki
#define LOKI_SINGLETON_INSTANCE_DEFINITION(SHOLDER) \ #define LOKI_SINGLETON_INSTANCE_DEFINITION(SHOLDER) \
namespace Loki \ namespace Loki \
{ \ { \
template<> \ template<> \
SHOLDER::ObjectType& Singleton<SHOLDER::ObjectType>::Instance() \ SHOLDER::ObjectType& Singleton<SHOLDER::ObjectType>::Instance() \
{ \ { \
return SHOLDER::Instance(); \ return SHOLDER::Instance(); \
} \ } \
} }
@ -897,6 +897,9 @@ namespace Loki \
#endif // SINGLETON_INC_ #endif // SINGLETON_INC_
// $Log$ // $Log$
// Revision 1.31 2006/06/19 12:39:08 syntheticpp
// replace tabs with 4 spaces
//
// Revision 1.30 2006/05/20 10:23:07 syntheticpp // Revision 1.30 2006/05/20 10:23:07 syntheticpp
// add warnings in the documentation about the special lifetime when using SmallObjects // add warnings in the documentation about the special lifetime when using SmallObjects
// //

View file

@ -218,7 +218,7 @@ namespace Loki
std::size_t maxSmallObjectSize = LOKI_MAX_SMALL_OBJECT_SIZE, std::size_t maxSmallObjectSize = LOKI_MAX_SMALL_OBJECT_SIZE,
std::size_t objectAlignSize = LOKI_DEFAULT_OBJECT_ALIGNMENT, std::size_t objectAlignSize = LOKI_DEFAULT_OBJECT_ALIGNMENT,
template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME, template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME,
class MutexPolicy = LOKI_DEFAULT_MUTEX class MutexPolicy = LOKI_DEFAULT_MUTEX
> >
class AllocatorSingleton : public SmallObjAllocator class AllocatorSingleton : public SmallObjAllocator
{ {
@ -283,7 +283,7 @@ namespace Loki
std::size_t MSOS, std::size_t MSOS,
std::size_t OAS, std::size_t OAS,
template <class> class LP, template <class> class LP,
class MX class MX
> >
void AllocatorSingleton< TM, CS, MSOS, OAS, LP, MX >::ClearExtraMemory( void ) void AllocatorSingleton< TM, CS, MSOS, OAS, LP, MX >::ClearExtraMemory( void )
{ {
@ -299,7 +299,7 @@ namespace Loki
std::size_t MSOS, std::size_t MSOS,
std::size_t OAS, std::size_t OAS,
template <class> class LP, template <class> class LP,
class MX class MX
> >
bool AllocatorSingleton< TM, CS, MSOS, OAS, LP, MX >::IsCorrupted( void ) bool AllocatorSingleton< TM, CS, MSOS, OAS, LP, MX >::IsCorrupted( void )
{ {
@ -327,7 +327,7 @@ namespace Loki
std::size_t MSOS, std::size_t MSOS,
std::size_t OAS, std::size_t OAS,
template <class> class LP, template <class> class LP,
class MX class MX
> >
inline unsigned int GetLongevity( inline unsigned int GetLongevity(
AllocatorSingleton< TM, CS, MSOS, OAS, LP, MX > * ) AllocatorSingleton< TM, CS, MSOS, OAS, LP, MX > * )
@ -421,7 +421,7 @@ namespace Loki
std::size_t maxSmallObjectSize, std::size_t maxSmallObjectSize,
std::size_t objectAlignSize, std::size_t objectAlignSize,
template <class> class LifetimePolicy, template <class> class LifetimePolicy,
class MutexPolicy class MutexPolicy
> >
class SmallObjectBase class SmallObjectBase
{ {
@ -578,7 +578,7 @@ namespace Loki
std::size_t maxSmallObjectSize = LOKI_MAX_SMALL_OBJECT_SIZE, std::size_t maxSmallObjectSize = LOKI_MAX_SMALL_OBJECT_SIZE,
std::size_t objectAlignSize = LOKI_DEFAULT_OBJECT_ALIGNMENT, std::size_t objectAlignSize = LOKI_DEFAULT_OBJECT_ALIGNMENT,
template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME, template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME,
class MutexPolicy = LOKI_DEFAULT_MUTEX class MutexPolicy = LOKI_DEFAULT_MUTEX
> >
class SmallObject : public SmallObjectBase< ThreadingModel, chunkSize, class SmallObject : public SmallObjectBase< ThreadingModel, chunkSize,
maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy > maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
@ -614,7 +614,7 @@ namespace Loki
std::size_t maxSmallObjectSize = LOKI_MAX_SMALL_OBJECT_SIZE, std::size_t maxSmallObjectSize = LOKI_MAX_SMALL_OBJECT_SIZE,
std::size_t objectAlignSize = LOKI_DEFAULT_OBJECT_ALIGNMENT, std::size_t objectAlignSize = LOKI_DEFAULT_OBJECT_ALIGNMENT,
template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME, template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME,
class MutexPolicy = LOKI_DEFAULT_MUTEX class MutexPolicy = LOKI_DEFAULT_MUTEX
> >
class SmallValueObject : public SmallObjectBase< ThreadingModel, chunkSize, class SmallValueObject : public SmallObjectBase< ThreadingModel, chunkSize,
maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy > maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
@ -634,6 +634,9 @@ namespace Loki
// Nov. 26, 2004: re-implemented by Rich Sposato. // Nov. 26, 2004: re-implemented by Rich Sposato.
// //
// $Log$ // $Log$
// Revision 1.30 2006/06/19 12:39:08 syntheticpp
// replace tabs with 4 spaces
//
// Revision 1.29 2006/03/08 17:07:11 syntheticpp // Revision 1.29 2006/03/08 17:07:11 syntheticpp
// replace tabs with 4 spaces in all files // replace tabs with 4 spaces in all files
// //

View file

@ -884,7 +884,7 @@ namespace Loki
class ConversionPolicy = DisallowConversion, class ConversionPolicy = DisallowConversion,
template <class> class CheckingPolicy = AssertCheck, template <class> class CheckingPolicy = AssertCheck,
template <class> class StoragePolicy = DefaultSPStorage, template <class> class StoragePolicy = DefaultSPStorage,
template<class> class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS template<class> class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS
> >
struct SmartPtrDef struct SmartPtrDef
{ {
@ -895,7 +895,7 @@ namespace Loki
ConversionPolicy, ConversionPolicy,
CheckingPolicy, CheckingPolicy,
StoragePolicy, StoragePolicy,
ConstnessPolicy ConstnessPolicy
> >
type; type;
}; };
@ -1525,6 +1525,9 @@ namespace std
// $Log$ // $Log$
// Revision 1.32 2006/06/19 12:39:08 syntheticpp
// replace tabs with 4 spaces
//
// Revision 1.31 2006/05/30 14:30:19 syntheticpp // Revision 1.31 2006/05/30 14:30:19 syntheticpp
// add warning about mt bug // add warning about mt bug
// //

View file

@ -122,7 +122,7 @@ public:
typedef typename A::pointer iterator; typedef typename A::pointer iterator;
typedef typename A::const_pointer const_iterator; typedef typename A::const_pointer const_iterator;
AllocatorStringStorage() AllocatorStringStorage()
: A(), pData_(0) : A(), pData_(0)
{ {
} }
@ -231,12 +231,12 @@ public:
swap(newStr); swap(newStr);
} }
template <class ForwardIterator> template <class ForwardIterator>
void append(ForwardIterator b, ForwardIterator e) void append(ForwardIterator b, ForwardIterator e)
{ {
const size_type const size_type
sz = std::distance(b, e), sz = std::distance(b, e),
neededCapacity = size() + sz; neededCapacity = size() + sz;
if (capacity() < neededCapacity) if (capacity() < neededCapacity)
{ {
@ -245,7 +245,7 @@ public:
assert(!(le(begin(), &*b) && le(&*b, end()))); assert(!(le(begin(), &*b) && le(&*b, end())));
reserve(neededCapacity); reserve(neededCapacity);
} }
std::copy(b, e, end()); std::copy(b, e, end());
pData_->pEnd_ += sz; pData_->pEnd_ += sz;
} }

View file

@ -90,7 +90,7 @@ public:
typedef typename Storage::const_iterator const_iterator; typedef typename Storage::const_iterator const_iterator;
typedef typename Storage::allocator_type allocator_type; typedef typename Storage::allocator_type allocator_type;
typedef typename allocator_type::size_type size_type; typedef typename allocator_type::size_type size_type;
typedef typename Storage::reference reference; typedef typename Storage::reference reference;
private: private:
union union

View file

@ -17,14 +17,14 @@
namespace flex_string_details namespace flex_string_details
{ {
template <class InIt, class OutIt> template <class InIt, class OutIt>
OutIt copy_n(InIt b, typename std::iterator_traits<InIt>::difference_type n, OutIt d) OutIt copy_n(InIt b, typename std::iterator_traits<InIt>::difference_type n, OutIt d)
{ {
for (; n != 0; --n, ++b, ++d) for (; n != 0; --n, ++b, ++d)
{ {
*d = *b; *d = *b;
} }
return d; return d;
} }
template <class Pod, class T> template <class Pod, class T>

View file

@ -170,7 +170,7 @@ class flex_string : private Storage
struct Invariant struct Invariant
{ {
#ifndef NDEBUG #ifndef NDEBUG
Invariant(const flex_string& s) : s_(s) Invariant(const flex_string& s) : s_(s)
{ {
assert(s_.Sane()); assert(s_.Sane());
} }
@ -181,9 +181,9 @@ class flex_string : private Storage
private: private:
const flex_string& s_; const flex_string& s_;
#else #else
Invariant(const flex_string&) {} Invariant(const flex_string&) {}
#endif #endif
Invariant& operator=(const Invariant&); Invariant& operator=(const Invariant&);
}; };
public: public:
@ -217,9 +217,9 @@ public:
private: private:
static size_type Min(size_type lhs, size_type rhs) static size_type Min(size_type lhs, size_type rhs)
{ return lhs < rhs ? lhs : rhs; } { return lhs < rhs ? lhs : rhs; }
static size_type Max(size_type lhs, size_type rhs) static size_type Max(size_type lhs, size_type rhs)
{ return lhs > rhs ? lhs : rhs; } { return lhs > rhs ? lhs : rhs; }
static void Procust(size_type& n, size_type nmax) static void Procust(size_type& n, size_type nmax)
{ if (n > nmax) n = nmax; } { if (n > nmax) n = nmax; }
public: public:
@ -364,7 +364,7 @@ public:
flex_string& operator+=(const value_type c) flex_string& operator+=(const value_type c)
{ {
push_back(c); push_back(c);
return *this; return *this;
} }
@ -376,20 +376,20 @@ public:
{ {
const size_type sz = str.size(); const size_type sz = str.size();
Enforce(pos <= sz, static_cast<std::out_of_range*>(0), ""); Enforce(pos <= sz, static_cast<std::out_of_range*>(0), "");
Procust(n, sz - pos); Procust(n, sz - pos);
return append(str.data() + pos, n); return append(str.data() + pos, n);
} }
flex_string& append(const value_type* s, const size_type n) flex_string& append(const value_type* s, const size_type n)
{ {
Invariant checker(*this); Invariant checker(*this);
(void) checker; (void) checker;
static std::less_equal<const value_type*> le; static std::less_equal<const value_type*> le;
if (le(&*begin(), s) && le(s, &*end())) // aliasing if (le(&*begin(), s) && le(s, &*end())) // aliasing
{ {
const size_type offset = s - &*begin(); const size_type offset = s - &*begin();
Storage::reserve(size() + n); Storage::reserve(size() + n);
s = &*begin() + offset; s = &*begin() + offset;
} }
Storage::append(s, s + n); Storage::append(s, s + n);
return *this; return *this;
@ -407,7 +407,7 @@ public:
template<class InputIterator> template<class InputIterator>
flex_string& append(InputIterator first, InputIterator last) flex_string& append(InputIterator first, InputIterator last)
{ {
insert(end(), first, last); insert(end(), first, last);
return *this; return *this;
} }
@ -418,7 +418,7 @@ public:
{ {
reserve(cap << 1u); reserve(cap << 1u);
} }
Storage::append(&c, &c + 1); Storage::append(&c, &c + 1);
} }
flex_string& assign(const flex_string& str) flex_string& assign(const flex_string& str)
@ -430,25 +430,25 @@ public:
flex_string& assign(const flex_string& str, const size_type pos, flex_string& assign(const flex_string& str, const size_type pos,
size_type n) size_type n)
{ {
const size_type sz = str.size(); const size_type sz = str.size();
Enforce(pos <= sz, static_cast<std::out_of_range*>(0), ""); Enforce(pos <= sz, static_cast<std::out_of_range*>(0), "");
Procust(n, sz - pos); Procust(n, sz - pos);
return assign(str.data() + pos, n); return assign(str.data() + pos, n);
} }
flex_string& assign(const value_type* s, const size_type n) flex_string& assign(const value_type* s, const size_type n)
{ {
Invariant checker(*this); Invariant checker(*this);
(void) checker; (void) checker;
if (size() >= n) if (size() >= n)
{ {
std::copy(s, s + n, begin()); std::copy(s, s + n, begin());
resize(n); resize(n);
} }
else else
{ {
const value_type *const s2 = s + size(); const value_type *const s2 = s + size();
std::copy(s, s2, begin()); std::copy(s, s2, begin());
append(s2, n - size()); append(s2, n - size());
} }
return *this; return *this;
@ -468,15 +468,15 @@ public:
size_type pos2, size_type n) size_type pos2, size_type n)
{ {
Enforce(pos2 <= str.length(), static_cast<std::out_of_range*>(0), ""); Enforce(pos2 <= str.length(), static_cast<std::out_of_range*>(0), "");
Procust(n, str.length() - pos2); Procust(n, str.length() - pos2);
return insert(pos1, str.data() + pos2, n); return insert(pos1, str.data() + pos2, n);
} }
flex_string& insert(size_type pos, const value_type* s, size_type n) flex_string& insert(size_type pos, const value_type* s, size_type n)
{ {
Enforce(pos <= length(), static_cast<std::out_of_range*>(0), ""); Enforce(pos <= length(), static_cast<std::out_of_range*>(0), "");
insert(begin() + pos, s, s + n); insert(begin() + pos, s, s + n);
return *this; return *this;
} }
flex_string& insert(size_type pos, const value_type* s) flex_string& insert(size_type pos, const value_type* s)
@ -485,13 +485,13 @@ public:
flex_string& insert(size_type pos, size_type n, value_type c) flex_string& insert(size_type pos, size_type n, value_type c)
{ {
Enforce(pos <= length(), static_cast<std::out_of_range*>(0), ""); Enforce(pos <= length(), static_cast<std::out_of_range*>(0), "");
insert(begin() + pos, n, c); insert(begin() + pos, n, c);
return *this; return *this;
} }
iterator insert(const iterator p, const value_type c) iterator insert(const iterator p, const value_type c)
{ {
const size_type pos = p - begin(); const size_type pos = p - begin();
insert(p, 1, c); insert(p, 1, c);
return begin() + pos; return begin() + pos;
} }
@ -502,122 +502,122 @@ private:
flex_string& InsertImplDiscr(iterator p, flex_string& InsertImplDiscr(iterator p,
size_type n, value_type c, Selector<1>) size_type n, value_type c, Selector<1>)
{ {
Invariant checker(*this); Invariant checker(*this);
(void) checker; (void) checker;
assert(p >= begin() && p <= end()); assert(p >= begin() && p <= end());
if (capacity() - size() < n) if (capacity() - size() < n)
{ {
const size_type sz = p - begin(); const size_type sz = p - begin();
reserve(size() + n); reserve(size() + n);
p = begin() + sz; p = begin() + sz;
} }
const iterator oldEnd = end(); const iterator oldEnd = end();
//if (p + n < oldEnd) // replaced because of crash (pk) //if (p + n < oldEnd) // replaced because of crash (pk)
if( n < size_type(oldEnd - p)) if( n < size_type(oldEnd - p))
{ {
append(oldEnd - n, oldEnd); append(oldEnd - n, oldEnd);
//std::copy( //std::copy(
// reverse_iterator(oldEnd - n), // reverse_iterator(oldEnd - n),
// reverse_iterator(p), // reverse_iterator(p),
// reverse_iterator(oldEnd)); // reverse_iterator(oldEnd));
flex_string_details::pod_move(&*p, &*oldEnd - n, &*p + n); flex_string_details::pod_move(&*p, &*oldEnd - n, &*p + n);
std::fill(p, p + n, c); std::fill(p, p + n, c);
} }
else else
{ {
append(n - (end() - p), c); append(n - (end() - p), c);
append(p, oldEnd); append(p, oldEnd);
std::fill(p, oldEnd, c); std::fill(p, oldEnd, c);
} }
return *this; return *this;
} }
template<class InputIterator> template<class InputIterator>
flex_string& InsertImplDiscr(iterator i, flex_string& InsertImplDiscr(iterator i,
InputIterator b, InputIterator e, Selector<0>) InputIterator b, InputIterator e, Selector<0>)
{ {
InsertImpl(i, b, e, InsertImpl(i, b, e,
typename std::iterator_traits<InputIterator>::iterator_category()); typename std::iterator_traits<InputIterator>::iterator_category());
return *this; return *this;
} }
template <class FwdIterator> template <class FwdIterator>
void InsertImpl(iterator i, void InsertImpl(iterator i,
FwdIterator s1, FwdIterator s2, std::forward_iterator_tag) FwdIterator s1, FwdIterator s2, std::forward_iterator_tag)
{ {
Invariant checker(*this); Invariant checker(*this);
(void) checker; (void) checker;
const size_type pos = i - begin(); const size_type pos = i - begin();
const typename std::iterator_traits<FwdIterator>::difference_type n2 = const typename std::iterator_traits<FwdIterator>::difference_type n2 =
std::distance(s1, s2); std::distance(s1, s2);
assert(n2 >= 0); assert(n2 >= 0);
using namespace flex_string_details; using namespace flex_string_details;
assert(pos <= size()); assert(pos <= size());
const typename std::iterator_traits<FwdIterator>::difference_type maxn2 = const typename std::iterator_traits<FwdIterator>::difference_type maxn2 =
capacity() - size(); capacity() - size();
if (maxn2 < n2) if (maxn2 < n2)
{ {
// realloc the string // realloc the string
static const std::less_equal<const value_type*> le = static const std::less_equal<const value_type*> le =
std::less_equal<const value_type*>(); std::less_equal<const value_type*>();
assert(!(le(&*begin(), &*s1) && le(&*s1, &*end()))); assert(!(le(&*begin(), &*s1) && le(&*s1, &*end())));
reserve(size() + n2); reserve(size() + n2);
i = begin() + pos; i = begin() + pos;
} }
if (pos + n2 <= size()) if (pos + n2 <= size())
{ {
//const iterator oldEnd = end(); //const iterator oldEnd = end();
//Storage::append(oldEnd - n2, n2); //Storage::append(oldEnd - n2, n2);
//std::copy(i, oldEnd - n2, i + n2); //std::copy(i, oldEnd - n2, i + n2);
const iterator tailBegin = end() - n2; const iterator tailBegin = end() - n2;
Storage::append(tailBegin, tailBegin + n2); Storage::append(tailBegin, tailBegin + n2);
//std::copy(i, tailBegin, i + n2); //std::copy(i, tailBegin, i + n2);
std::copy(reverse_iterator(tailBegin), reverse_iterator(i), std::copy(reverse_iterator(tailBegin), reverse_iterator(i),
reverse_iterator(tailBegin + n2)); reverse_iterator(tailBegin + n2));
std::copy(s1, s2, i); std::copy(s1, s2, i);
} }
else else
{ {
FwdIterator t = s1; FwdIterator t = s1;
const size_type old_size = size(); const size_type old_size = size();
std::advance(t, old_size - pos); std::advance(t, old_size - pos);
assert(std::distance(t, s2) >= 0); assert(std::distance(t, s2) >= 0);
Storage::append(t, s2); Storage::append(t, s2);
Storage::append(data() + pos, data() + old_size); Storage::append(data() + pos, data() + old_size);
std::copy(s1, t, i); std::copy(s1, t, i);
} }
} }
template <class InputIterator> template <class InputIterator>
void InsertImpl(iterator i1, iterator i2, void InsertImpl(iterator i1, iterator i2,
InputIterator b, InputIterator e, std::input_iterator_tag) InputIterator b, InputIterator e, std::input_iterator_tag)
{ {
flex_string temp(begin(), i1); flex_string temp(begin(), i1);
for (; b != e; ++b) for (; b != e; ++b)
{ {
temp.push_back(*b); temp.push_back(*b);
} }
temp.append(i2, end()); temp.append(i2, end());
swap(temp); swap(temp);
} }
public: public:
template <class ItOrLength, class ItOrChar> template <class ItOrLength, class ItOrChar>
void insert(iterator p, ItOrLength first_or_n, ItOrChar last_or_c) void insert(iterator p, ItOrLength first_or_n, ItOrChar last_or_c)
{ {
Selector<std::numeric_limits<ItOrLength>::is_specialized> sel; Selector<std::numeric_limits<ItOrLength>::is_specialized> sel;
InsertImplDiscr(p, first_or_n, last_or_c, sel); InsertImplDiscr(p, first_or_n, last_or_c, sel);
} }
flex_string& erase(size_type pos = 0, size_type n = npos) flex_string& erase(size_type pos = 0, size_type n = npos)
{ {
Invariant checker(*this); Invariant checker(*this);
(void) checker; (void) checker;
Enforce(pos <= length(), static_cast<std::out_of_range*>(0), ""); Enforce(pos <= length(), static_cast<std::out_of_range*>(0), "");
Procust(n, length() - pos); Procust(n, length() - pos);
std::copy(begin() + pos + n, end(), begin() + pos); std::copy(begin() + pos + n, end(), begin() + pos);
resize(length() - n); resize(length() - n);
return *this; return *this;
} }
@ -653,28 +653,28 @@ public:
// Replaces at most n1 chars of *this, starting with pos, // Replaces at most n1 chars of *this, starting with pos,
// with at most n2 chars of str. // with at most n2 chars of str.
// str must have at least n2 chars. // str must have at least n2 chars.
flex_string& replace(const size_type pos, size_type n1, flex_string& replace(const size_type pos, size_type n1,
const value_type* s1, const size_type n2) const value_type* s1, const size_type n2)
{ {
Invariant checker(*this); Invariant checker(*this);
(void) checker; (void) checker;
Enforce(pos <= size(), (std::out_of_range*)0, ""); Enforce(pos <= size(), (std::out_of_range*)0, "");
Procust(n1, size() - pos); Procust(n1, size() - pos);
const iterator b = begin() + pos; const iterator b = begin() + pos;
return replace(b, b + n1, s1, s1 + n2); return replace(b, b + n1, s1, s1 + n2);
using namespace flex_string_details; using namespace flex_string_details;
const int delta = int(n2 - n1); const int delta = int(n2 - n1);
static const std::less_equal<const value_type*> le; static const std::less_equal<const value_type*> le;
const bool aliased = le(&*begin(), s1) && le(s1, &*end()); const bool aliased = le(&*begin(), s1) && le(s1, &*end());
// From here on we're dealing with an aliased replace // From here on we're dealing with an aliased replace
if (delta <= 0) if (delta <= 0)
{ {
// simple case, we're shrinking // simple case, we're shrinking
pod_move(s1, s1 + n2, &*begin() + pos); pod_move(s1, s1 + n2, &*begin() + pos);
pod_move(&*begin() + pos + n1, &*end(), &*begin() + pos + n1 + delta); pod_move(&*begin() + pos + n1, &*end(), &*begin() + pos + n1 + delta);
resize(size() + delta); resize(size() + delta);
return *this; return *this;
} }
// From here on we deal with aliased growth // From here on we deal with aliased growth
@ -739,14 +739,14 @@ public:
// str must have at least n2 chars. // str must have at least n2 chars.
template <class StrOrLength, class NumOrChar> template <class StrOrLength, class NumOrChar>
flex_string& replace(size_type pos, size_type n1, flex_string& replace(size_type pos, size_type n1,
StrOrLength s_or_n2, NumOrChar n_or_c) StrOrLength s_or_n2, NumOrChar n_or_c)
{ {
Invariant checker(*this); Invariant checker(*this);
(void) checker; (void) checker;
Enforce(pos <= size(), static_cast<std::out_of_range*>(0), ""); Enforce(pos <= size(), static_cast<std::out_of_range*>(0), "");
Procust(n1, length() - pos); Procust(n1, length() - pos);
const iterator b = begin() + pos; const iterator b = begin() + pos;
return replace(b, b + n1, s_or_n2, n_or_c); return replace(b, b + n1, s_or_n2, n_or_c);
} }
flex_string& replace(iterator i1, iterator i2, const flex_string& str) flex_string& replace(iterator i1, iterator i2, const flex_string& str)
@ -759,87 +759,87 @@ private:
flex_string& ReplaceImplDiscr(iterator i1, iterator i2, flex_string& ReplaceImplDiscr(iterator i1, iterator i2,
const value_type* s, size_type n, Selector<2>) const value_type* s, size_type n, Selector<2>)
{ {
assert(i1 <= i2); assert(i1 <= i2);
assert(begin() <= i1 && i1 <= end()); assert(begin() <= i1 && i1 <= end());
assert(begin() <= i2 && i2 <= end()); assert(begin() <= i2 && i2 <= end());
return replace(i1, i2, s, s + n); return replace(i1, i2, s, s + n);
} }
flex_string& ReplaceImplDiscr(iterator i1, iterator i2, flex_string& ReplaceImplDiscr(iterator i1, iterator i2,
size_type n2, value_type c, Selector<1>) size_type n2, value_type c, Selector<1>)
{ {
const size_type n1 = i2 - i1; const size_type n1 = i2 - i1;
if (n1 > n2) if (n1 > n2)
{ {
std::fill(i1, i1 + n2, c); std::fill(i1, i1 + n2, c);
erase(i1 + n2, i2); erase(i1 + n2, i2);
} }
else else
{ {
std::fill(i1, i2, c); std::fill(i1, i2, c);
insert(i2, n2 - n1, c); insert(i2, n2 - n1, c);
} }
return *this; return *this;
} }
template <class InputIterator> template <class InputIterator>
flex_string& ReplaceImplDiscr(iterator i1, iterator i2, flex_string& ReplaceImplDiscr(iterator i1, iterator i2,
InputIterator b, InputIterator e, Selector<0>) InputIterator b, InputIterator e, Selector<0>)
{ {
ReplaceImpl(i1, i2, b, e, ReplaceImpl(i1, i2, b, e,
typename std::iterator_traits<InputIterator>::iterator_category()); typename std::iterator_traits<InputIterator>::iterator_category());
return *this; return *this;
} }
template <class FwdIterator> template <class FwdIterator>
void ReplaceImpl(iterator i1, iterator i2, void ReplaceImpl(iterator i1, iterator i2,
FwdIterator s1, FwdIterator s2, std::forward_iterator_tag) FwdIterator s1, FwdIterator s2, std::forward_iterator_tag)
{ {
Invariant checker(*this); Invariant checker(*this);
(void) checker; (void) checker;
const typename std::iterator_traits<iterator>::difference_type n1 = const typename std::iterator_traits<iterator>::difference_type n1 =
i2 - i1; i2 - i1;
assert(n1 >= 0); assert(n1 >= 0);
const typename std::iterator_traits<FwdIterator>::difference_type n2 = const typename std::iterator_traits<FwdIterator>::difference_type n2 =
std::distance(s1, s2); std::distance(s1, s2);
assert(n2 >= 0); assert(n2 >= 0);
// Handle aliased replace // Handle aliased replace
static const std::less_equal<const value_type*> le = static const std::less_equal<const value_type*> le =
std::less_equal<const value_type*>(); std::less_equal<const value_type*>();
const bool aliased = le(&*begin(), &*s1) && le(&*s1, &*end()); const bool aliased = le(&*begin(), &*s1) && le(&*s1, &*end());
if (aliased /* && capacity() < size() - n1 + n2 */) if (aliased /* && capacity() < size() - n1 + n2 */)
{ {
// Aliased replace, copy to new string // Aliased replace, copy to new string
flex_string temp; flex_string temp;
temp.reserve(size() - n1 + n2); temp.reserve(size() - n1 + n2);
temp.append(begin(), i1).append(s1, s2).append(i2, end()); temp.append(begin(), i1).append(s1, s2).append(i2, end());
swap(temp); swap(temp);
return; return;
} }
if (n1 > n2) if (n1 > n2)
{ {
// shrinks // shrinks
std::copy(s1, s2, i1); std::copy(s1, s2, i1);
erase(i1 + n2, i2); erase(i1 + n2, i2);
} }
else else
{ {
// grows // grows
flex_string_details::copy_n(s1, n1, i1); flex_string_details::copy_n(s1, n1, i1);
std::advance(s1, n1); std::advance(s1, n1);
insert(i2, s1, s2); insert(i2, s1, s2);
} }
} }
template <class InputIterator> template <class InputIterator>
void ReplaceImpl(iterator i1, iterator i2, void ReplaceImpl(iterator i1, iterator i2,
InputIterator b, InputIterator e, std::input_iterator_tag) InputIterator b, InputIterator e, std::input_iterator_tag)
{ {
flex_string temp(begin(), i1); flex_string temp(begin(), i1);
temp.append(b, e).append(i2, end()); temp.append(b, e).append(i2, end());
swap(temp); swap(temp);
} }
public: public:
@ -847,11 +847,11 @@ public:
flex_string& replace(iterator i1, iterator i2, flex_string& replace(iterator i1, iterator i2,
T1 first_or_n_or_s, T2 last_or_c_or_n) T1 first_or_n_or_s, T2 last_or_c_or_n)
{ {
const bool const bool
num1 = std::numeric_limits<T1>::is_specialized, num1 = std::numeric_limits<T1>::is_specialized,
num2 = std::numeric_limits<T2>::is_specialized; num2 = std::numeric_limits<T2>::is_specialized;
return ReplaceImplDiscr(i1, i2, first_or_n_or_s, last_or_c_or_n, return ReplaceImplDiscr(i1, i2, first_or_n_or_s, last_or_c_or_n,
Selector<num1 ? (num2 ? 1 : -1) : (num2 ? 2 : 0)>()); Selector<num1 ? (num2 ? 1 : -1) : (num2 ? 2 : 0)>());
} }
size_type copy(value_type* s, size_type n, size_type pos = 0) const size_type copy(value_type* s, size_type n, size_type pos = 0) const
@ -1055,7 +1055,7 @@ public:
int compare(const flex_string& str) const int compare(const flex_string& str) const
{ {
// FIX due to Goncalo N M de Carvalho July 18, 2005 // FIX due to Goncalo N M de Carvalho July 18, 2005
return compare(0, size(), str); return compare(0, size(), str);
} }
int compare(size_type pos1, size_type n1, int compare(size_type pos1, size_type n1,
@ -1069,20 +1069,20 @@ public:
int compare(size_type pos1, size_type n1, int compare(size_type pos1, size_type n1,
const value_type* s) const const value_type* s) const
{ {
return compare(pos1, n1, s, traits_type::length(s)); return compare(pos1, n1, s, traits_type::length(s));
} }
int compare(size_type pos1, size_type n1, int compare(size_type pos1, size_type n1,
const value_type* s, size_type n2) const const value_type* s, size_type n2) const
{ {
Enforce(pos1 <= size(), static_cast<std::out_of_range*>(0), ""); Enforce(pos1 <= size(), static_cast<std::out_of_range*>(0), "");
Procust(n1, size() - pos1); Procust(n1, size() - pos1);
const int r = traits_type::compare(data(), s, Min(n1, n2)); const int r = traits_type::compare(data(), s, Min(n1, n2));
return return
r != 0 ? r : r != 0 ? r :
n1 > n2 ? 1 : n1 > n2 ? 1 :
n1 < n2 ? -1 : n1 < n2 ? -1 :
0; 0;
} }
int compare(size_type pos1, size_type n1, int compare(size_type pos1, size_type n1,
@ -1095,7 +1095,7 @@ public:
int compare(const value_type* s) const int compare(const value_type* s) const
{ {
return traits_type::compare(data(), s, Max(length(),traits_type::length(s))); return traits_type::compare(data(), s, Max(length(),traits_type::length(s)));
} }
}; };
@ -1257,7 +1257,7 @@ std::basic_istream<typename flex_string<E, T, A, S>::value_type,
typename flex_string<E, T, A, S>::traits_type>& typename flex_string<E, T, A, S>::traits_type>&
operator>>( operator>>(
std::basic_istream<typename flex_string<E, T, A, S>::value_type, std::basic_istream<typename flex_string<E, T, A, S>::value_type,
typename flex_string<E, T, A, S>::traits_type>& is, typename flex_string<E, T, A, S>::traits_type>& is,
flex_string<E, T, A, S>& str); flex_string<E, T, A, S>& str);
template <typename E, class T, class A, class S> template <typename E, class T, class A, class S>
@ -1265,7 +1265,7 @@ std::basic_ostream<typename flex_string<E, T, A, S>::value_type,
typename flex_string<E, T, A, S>::traits_type>& typename flex_string<E, T, A, S>::traits_type>&
operator<<( operator<<(
std::basic_ostream<typename flex_string<E, T, A, S>::value_type, std::basic_ostream<typename flex_string<E, T, A, S>::value_type,
typename flex_string<E, T, A, S>::traits_type>& os, typename flex_string<E, T, A, S>::traits_type>& os,
const flex_string<E, T, A, S>& str) const flex_string<E, T, A, S>& str)
{ return os << str.c_str(); } { return os << str.c_str(); }

View file

@ -120,7 +120,7 @@ public:
typedef E* iterator; typedef E* iterator;
typedef const E* const_iterator; typedef const E* const_iterator;
typedef A allocator_type; typedef A allocator_type;
typedef typename A::reference reference; typedef typename A::reference reference;
SimpleStringStorage(const SimpleStringStorage& rhs) SimpleStringStorage(const SimpleStringStorage& rhs)
@ -219,14 +219,14 @@ public:
template <class InputIterator> template <class InputIterator>
void append(InputIterator b, InputIterator e) void append(InputIterator b, InputIterator e)
{ {
const size_type const size_type
sz = std::distance(b, e), sz = std::distance(b, e),
neededCapacity = size() + sz; neededCapacity = size() + sz;
if (capacity() < neededCapacity) if (capacity() < neededCapacity)
{ {
static std::less_equal<const E*> le; static std::less_equal<const E*> le;
(void) le; (void) le;
assert(!(le(begin(), &*b) && le(&*b, end()))); // no aliasing assert(!(le(begin(), &*b) && le(&*b, end()))); // no aliasing
reserve(neededCapacity); reserve(neededCapacity);
} }
std::copy(b, e, end()); std::copy(b, e, end());
@ -272,8 +272,8 @@ template <typename E, class A>
const typename SimpleStringStorage<E, A>::Data const typename SimpleStringStorage<E, A>::Data
SimpleStringStorage<E, A>::emptyString_; SimpleStringStorage<E, A>::emptyString_;
//{ //{
// const_cast<E*>(SimpleStringStorage<E, A>::emptyString_.buffer_), // const_cast<E*>(SimpleStringStorage<E, A>::emptyString_.buffer_),
// const_cast<E*>(SimpleStringStorage<E, A>::emptyString_.buffer_), // const_cast<E*>(SimpleStringStorage<E, A>::emptyString_.buffer_),
// { E() } // { E() }
//}; //};

View file

@ -86,10 +86,10 @@ public:
typedef const value_type* const_iterator; typedef const value_type* const_iterator;
typedef typename Storage::allocator_type allocator_type; typedef typename Storage::allocator_type allocator_type;
typedef typename allocator_type::size_type size_type; typedef typename allocator_type::size_type size_type;
typedef typename Storage::reference reference; typedef typename Storage::reference reference;
private: private:
enum { temp1 = threshold * sizeof(value_type) > sizeof(Storage) enum { temp1 = threshold * sizeof(value_type) > sizeof(Storage)
? threshold * sizeof(value_type) ? threshold * sizeof(value_type)
: sizeof(Storage) }; : sizeof(Storage) };
@ -128,7 +128,7 @@ private:
} }
public: public:
SmallStringOpt(const SmallStringOpt& s) SmallStringOpt(const SmallStringOpt& s)
{ {
if (s.Small()) if (s.Small())
{ {
@ -260,14 +260,14 @@ public:
else else
{ {
// append to a small string // append to a small string
const size_type const size_type
sz = std::distance(b, e), sz = std::distance(b, e),
neededCapacity = maxSmallString - buf_[maxSmallString] + sz; neededCapacity = maxSmallString - buf_[maxSmallString] + sz;
if (maxSmallString < neededCapacity) if (maxSmallString < neededCapacity)
{ {
// need to change storage strategy // need to change storage strategy
allocator_type alloc; allocator_type alloc;
Storage temp(alloc); Storage temp(alloc);
temp.reserve(neededCapacity); temp.reserve(neededCapacity);
temp.append(buf_, buf_ + maxSmallString - buf_[maxSmallString]); temp.append(buf_, buf_ + maxSmallString - buf_[maxSmallString]);
@ -278,7 +278,7 @@ public:
} }
else else
{ {
std::copy(b, e, buf_ + maxSmallString - buf_[maxSmallString]); std::copy(b, e, buf_ + maxSmallString - buf_[maxSmallString]);
buf_[maxSmallString] = buf_[maxSmallString] - value_type(sz); buf_[maxSmallString] = buf_[maxSmallString] - value_type(sz);
} }
} }

View file

@ -83,7 +83,7 @@ public: // protected:
typedef typename base::const_iterator const_iterator; typedef typename base::const_iterator const_iterator;
typedef A allocator_type; typedef A allocator_type;
typedef typename A::size_type size_type; typedef typename A::size_type size_type;
typedef typename A::reference reference; typedef typename A::reference reference;
VectorStringStorage(const VectorStringStorage& s) : base(s) VectorStringStorage(const VectorStringStorage& s) : base(s)
{ } { }
@ -137,32 +137,32 @@ public: // protected:
void reserve(size_type res_arg) void reserve(size_type res_arg)
{ {
assert(res_arg < max_size()); assert(res_arg < max_size());
base::reserve(res_arg + 1); base::reserve(res_arg + 1);
} }
template <class ForwardIterator> template <class ForwardIterator>
void append(ForwardIterator b, ForwardIterator e) void append(ForwardIterator b, ForwardIterator e)
{ {
const typename std::iterator_traits<ForwardIterator>::difference_type const typename std::iterator_traits<ForwardIterator>::difference_type
sz = std::distance(b, e); sz = std::distance(b, e);
assert(sz >= 0); assert(sz >= 0);
if (sz == 0) return; if (sz == 0) return;
base::reserve(base::size() + sz); base::reserve(base::size() + sz);
const value_type & v = *b; const value_type & v = *b;
struct OnBlockExit struct OnBlockExit
{ {
VectorStringStorage * that; VectorStringStorage * that;
~OnBlockExit() ~OnBlockExit()
{ {
that->base::push_back(value_type()); that->base::push_back(value_type());
} }
} onBlockExit = { this }; } onBlockExit = { this };
(void) onBlockExit; (void) onBlockExit;
assert(!base::empty()); assert(!base::empty());
assert(base::back() == value_type()); assert(base::back() == value_type());
base::back() = v; base::back() = v;
base::insert(base::end(), ++b, e); base::insert(base::end(), ++b, e);
} }
void resize(size_type n, E c) void resize(size_type n, E c)

View file

@ -7,7 +7,7 @@
namespace yasli_nstd namespace yasli_nstd
{ {
template <class T> template <class T>
class fill_iterator_base class fill_iterator_base
: public std::iterator< : public std::iterator<
std::random_access_iterator_tag, std::random_access_iterator_tag,
T, T,
@ -18,7 +18,7 @@ namespace yasli_nstd
}; };
template <class T> template <class T>
class fill_iterator_base<T&> class fill_iterator_base<T&>
: public std::iterator< : public std::iterator<
std::random_access_iterator_tag, std::random_access_iterator_tag,
T, T,
@ -50,7 +50,7 @@ namespace yasli_nstd
} }
template<class U> template<class U>
fill_iterator(const fill_iterator<U>& rhs) fill_iterator(const fill_iterator<U>& rhs)
: value_(rhs.value_), count_(rhs.count_) : value_(rhs.value_), count_(rhs.count_)
{ {
} }
@ -140,7 +140,7 @@ namespace yasli_nstd
template <class T> template <class T>
inline bool operator!=( inline bool operator!=(
const fill_iterator<T>& lhs, const fill_iterator<T>& lhs,
const fill_iterator<T>& rhs) const fill_iterator<T>& rhs)
{ // test for fill_iterator inequality { // test for fill_iterator inequality
return !(lhs == rhs); return !(lhs == rhs);
} }
@ -148,7 +148,7 @@ namespace yasli_nstd
template <class T> template <class T>
inline bool operator<( inline bool operator<(
const fill_iterator<T>& lhs, const fill_iterator<T>& lhs,
const fill_iterator<T>& rhs) const fill_iterator<T>& rhs)
{ {
return lhs.count_ < rhs.count_; return lhs.count_ < rhs.count_;
} }