本文整理汇总了C++中self_type类的典型用法代码示例。如果您正苦于以下问题:C++ self_type类的具体用法?C++ self_type怎么用?C++ self_type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了self_type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PointSet
PointSet( const self_type& P )
:
super(),
M_npoints( P.nPoints() ),
M_points( P.points() ),
M_points_face( P.M_points_face )
{}
示例2: inherit
void inherit( self_type & parent ) {
#ifdef DEBUGGING
assert( parent.size() <= size() );
#endif // DEBUGGING
memcpy( m_positions, parent.m_positions, parent.size() * sizeof(position_type) );
}
示例3: switch
inline void basic_val<T>::copy(self_type const& o)
{
if (type() == o.type())
{
switch (o.type())
{
case type_info::object:
o_ = o.o_;
break;
case type_info::array:
a_ = o.a_;
break;
case type_info::string:
s_ = o.s_;
break;
case type_info::int_:
i_ = o.i_;
break;
case type_info::double_:
d_ = o.d_;
break;
case type_info::bool_:
b_ = o.b_;
break;
default:
break;
}
return;
}
free();
switch (type_ = o.type())
{
case type_info::object:
new (&o_) object(o.o_);
break;
case type_info::array:
new (&a_) array(o.a_);
break;
case type_info::string:
new (&s_) string(o.s_);
break;
case type_info::int_:
i_ = o.i_;
break;
case type_info::double_:
d_ = o.d_;
break;
case type_info::bool_:
b_ = o.b_;
break;
default:
break;
}
}
示例4: AllocFailed
void
nsTString_CharT::ReplaceSubstring(const self_type& aTarget,
const self_type& aNewValue)
{
if (!ReplaceSubstring(aTarget, aNewValue, mozilla::fallible)) {
// Note that this may wildly underestimate the allocation that failed, as
// we could have been replacing multiple copies of aTarget.
AllocFailed(mLength + (aNewValue.Length() - aTarget.Length()));
}
}
示例5: BeginReading
int32_t
nsACString::RFind(const self_type& aStr, int32_t aOffset,
ComparatorFunc aComparator) const
{
const char_type* begin;
const char_type* end;
uint32_t selflen = BeginReading(&begin, &end);
const char_type* other;
uint32_t otherlen = aStr.BeginReading(&other);
if (selflen < otherlen) {
return -1;
}
if (aOffset < 0 || uint32_t(aOffset) > (selflen - otherlen)) {
end -= otherlen;
} else {
end = begin + aOffset;
}
for (const char_type* cur = end; cur >= begin; --cur) {
if (!aComparator(cur, other, otherlen)) {
return cur - begin;
}
}
return -1;
}
示例6: cross
self_type cross(self_type const& r) const
{
impl_type* pl = (impl_type*)this->data();
impl_type const* pr = (impl_type const*)r.data();
impl_type res = pl->cross(*pr);
return self_type(res(0), res(1), res(2));
}
示例7:
void
nsTSubstring_CharT::Assign(const self_type& aStr)
{
if (!Assign(aStr, fallible_t())) {
NS_ABORT_OOM(aStr.Length());
}
}
示例8: BeginReading
int32_t
nsACString::Find(const self_type& aStr, uint32_t aOffset,
ComparatorFunc c) const
{
const char_type *begin, *end;
uint32_t selflen = BeginReading(&begin, &end);
if (aOffset > selflen)
return -1;
const char_type *other;
uint32_t otherlen = aStr.BeginReading(&other);
if (otherlen > selflen - aOffset)
return -1;
// We want to stop searching otherlen characters before the end of the string
end -= otherlen;
for (const char_type *cur = begin + aOffset; cur <= end; ++cur) {
if (!c(cur, other, otherlen))
return cur - begin;
}
return -1;
}
示例9: push_back
void push_back( self_type & other, size_t idx ) {
size_t e = this->m_positions.size();
this->resize( e + 1 );
this->setPositionAt( e, other.getPositionAt( idx ) );
}
示例10: AllocFailed
void
nsTSubstring_CharT::Assign(const self_type& aStr)
{
if (!Assign(aStr, fallible_t())) {
AllocFailed(aStr.Length());
}
}
示例11: while
void
nsTString_CharT::ReplaceSubstring( const self_type& aTarget, const self_type& aNewValue )
{
if (aTarget.Length() == 0)
return;
uint32_t i = 0;
while (i < mLength)
{
int32_t r = FindSubstring(mData + i, mLength - i, aTarget.Data(), aTarget.Length(), false);
if (r == kNotFound)
break;
Replace(i + r, aTarget.Length(), aNewValue);
i += r + aNewValue.Length();
}
}
示例12: if
bool
nsTSubstring_CharT::Assign( const self_type& str, const fallible_t& )
{
// |str| could be sharable. we need to check its flags to know how to
// deal with it.
if (&str == this)
return true;
if (!str.mLength)
{
Truncate();
mFlags |= str.mFlags & F_VOIDED;
return true;
}
if (str.mFlags & F_SHARED)
{
// nice! we can avoid a string copy :-)
// |str| should be null-terminated
NS_ASSERTION(str.mFlags & F_TERMINATED, "shared, but not terminated");
::ReleaseData(mData, mFlags);
mData = str.mData;
mLength = str.mLength;
SetDataFlags(F_TERMINATED | F_SHARED);
// get an owning reference to the mData
nsStringBuffer::FromData(mData)->AddRef();
return true;
}
else if (str.mFlags & F_LITERAL)
{
NS_ABORT_IF_FALSE(str.mFlags & F_TERMINATED, "Unterminated literal");
AssignLiteral(str.mData, str.mLength);
return true;
}
// else, treat this like an ordinary assignment.
return Assign(str.Data(), str.Length(), fallible_t());
}
示例13: equal
bool equal(const self_type& rhs) const
{
if (valid_)
{
if (rhs.valid_)
return this->base() == rhs.base();
else
return false;
}
else
return !rhs.valid_;
}
示例14: BeginReading
PRInt32
nsACString::RFind(const self_type& aStr, PRInt32 aOffset, ComparatorFunc c) const
{
const char_type *begin, *end;
PRUint32 selflen = BeginReading(&begin, &end);
const char_type *other;
PRUint32 otherlen = aStr.BeginReading(&other);
if (selflen < otherlen)
return -1;
if (aOffset < 0 || aOffset > (selflen - otherlen))
end -= otherlen;
else
end = begin + aOffset;
for (const char_type *cur = end; cur >= begin; --cur) {
if (!c(cur, other, otherlen))
return cur - begin;
}
return -1;
}
示例15: hash_value
friend inline std::size_t hash_value(self_type const& x) {
std::size_t h = boost::hash<MatchState>()(x.match);
boost::hash_combine(h, x.input);
x.hashCombine(h);
return h;
}