Alien-boost-mini
view release on metacpan or search on metacpan
include/boost/container/string.hpp view on Meta::CPAN
void swap_data(basic_string_base& other)
{
if(this->is_short()){
if(other.is_short()){
repr_t tmp(this->members_.m_repr);
this->members_.m_repr = other.members_.m_repr;
other.members_.m_repr = tmp;
}
else{
short_t short_backup(this->members_.m_repr.short_repr());
this->members_.m_repr.short_repr().~short_t();
::new(&this->members_.m_repr.long_repr()) long_t(other.members_.m_repr.long_repr());
other.members_.m_repr.long_repr().~long_t();
::new(&other.members_.m_repr.short_repr()) short_t(short_backup);
}
}
else{
if(other.is_short()){
short_t short_backup(other.members_.m_repr.short_repr());
other.members_.m_repr.short_repr().~short_t();
::new(&other.members_.m_repr.long_repr()) long_t(this->members_.m_repr.long_repr());
this->members_.m_repr.long_repr().~long_t();
::new(&this->members_.m_repr.short_repr()) short_t(short_backup);
}
else{
boost::adl_move_swap(this->members_.m_repr.long_repr(), other.members_.m_repr.long_repr());
}
}
}
};
} //namespace dtl {
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
//! The basic_string class represents a Sequence of characters. It contains all the
//! usual operations of a Sequence, and, additionally, it contains standard string
//! operations such as search and concatenation.
//!
//! The basic_string class is parameterized by character type, and by that type's
//! Character Traits.
//!
//! This class has performance characteristics very much like vector<>, meaning,
//! for example, that it does not perform reference-count or copy-on-write, and that
//! concatenation of two strings is an O(N) operation.
//!
//! Some of basic_string's member functions use an unusual method of specifying positions
//! and ranges. In addition to the conventional method using iterators, many of
//! basic_string's member functions use a single value pos of type size_type to represent a
//! position (in which case the position is begin() + pos, and many of basic_string's
//! member functions use two values, pos and n, to represent a range. In that case pos is
//! the beginning of the range and n is its size. That is, the range is
//! [begin() + pos, begin() + pos + n).
//!
//! Note that the C++ standard does not specify the complexity of basic_string operations.
//! In this implementation, basic_string has performance characteristics very similar to
//! those of vector: access to a single character is O(1), while copy and concatenation
//! are O(N).
//!
//! In this implementation, begin(),
//! end(), rbegin(), rend(), operator[], c_str(), and data() do not invalidate iterators.
//! In this implementation, iterators are only invalidated by member functions that
//! explicitly change the string's contents.
//!
//! \tparam CharT The type of character it contains.
//! \tparam Traits The Character Traits type, which encapsulates basic character operations
//! \tparam Allocator The allocator, used for internal memory management.
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
template <class CharT, class Traits = std::char_traits<CharT>, class Allocator = new_allocator<CharT> >
#else
template <class CharT, class Traits, class Allocator>
#endif
class basic_string
: private dtl::basic_string_base<Allocator>
{
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private:
typedef allocator_traits<Allocator> allocator_traits_type;
BOOST_COPYABLE_AND_MOVABLE(basic_string)
typedef dtl::basic_string_base<Allocator> base_t;
static const typename base_t::size_type InternalBufferChars = base_t::InternalBufferChars;
protected:
// Allocator helper class to use a char_traits as a function object.
template <class Tr>
struct Eq_traits
{
//Compatibility with std::binary_function
typedef typename Tr::char_type first_argument_type;
typedef typename Tr::char_type second_argument_type;
typedef bool result_type;
bool operator()(const first_argument_type& x, const second_argument_type& y) const
{ return Tr::eq(x, y); }
};
template <class Tr>
struct Not_within_traits
{
typedef typename Tr::char_type argument_type;
typedef bool result_type;
typedef const typename Tr::char_type* Pointer;
const Pointer m_first;
const Pointer m_last;
Not_within_traits(Pointer f, Pointer l)
: m_first(f), m_last(l) {}
bool operator()(const typename Tr::char_type& x) const
{
return boost::container::find_if(m_first, m_last,
boost::container::bind1st(Eq_traits<Tr>(), x)) == m_last;
}
};
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
public:
//////////////////////////////////////////////
//
// types
( run in 0.773 second using v1.01-cache-2.11-cpan-140bd7fdf52 )