您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BSLS_ASSERT函数代码示例

51自学网 2021-06-01 19:52:56
  C++
这篇教程C++ BSLS_ASSERT函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中BSLS_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ BSLS_ASSERT函数的具体用法?C++ BSLS_ASSERT怎么用?C++ BSLS_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了BSLS_ASSERT函数的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: BSLS_ASSERT

inlineRESULT *allocate(int                                            *status,                 int                                             flags,                 const btlso::IPv4Address&                       peerAddress,                 btlso::StreamSocketFactory<btlso::IPv4Address> *factory,                 bdlma::Pool                                    *pool){    BSLS_ASSERT(factory); BSLS_ASSERT(pool); BSLS_ASSERT(status);    btlso::StreamSocket<btlso::IPv4Address> *socket_p = 0;    socket_p = factory->allocate();    if (!socket_p) {        return NULL;                                                  // RETURN    }    int rc = socket_p->setBlockingMode(btlso::Flag::e_BLOCKING_MODE);    BSLS_ASSERT(0 == rc);    while (1) {        int s = socket_p->connect(peerAddress);        if (0 == s) break;        if (btlso::SocketHandle::e_ERROR_INTERRUPTED != s) {            *status = e_FAILED; // Any negative number satisfies the contract.            factory->deallocate(socket_p);            return NULL;                                              // RETURN        }        if (flags & btlsc::Flag::k_ASYNC_INTERRUPT) {            *status = 1;  // Any positive number satisfies the contract.            factory->deallocate(socket_p);            return NULL;                                              // RETURN        }    }    RESULT *channel = new (*pool) RESULT(socket_p);    return channel;}
开发者ID:SuperV1234,项目名称:bde,代码行数:35,


示例2: BSLS_ASSERT

int baltzo::TimeZoneUtil::convertLocalToLocalTime(                                       LocalDatetime         *result,                                       const char            *targetTimeZoneId,                                       const bdlt::Datetime&  srcTime,                                       const char            *srcTimeZoneId,                                       DstPolicy::Enum        dstPolicy){    BSLS_ASSERT(result);    BSLS_ASSERT(targetTimeZoneId);    BSLS_ASSERT(srcTimeZoneId);    bdlt::DatetimeTz resultTz;    const int rc = convertLocalToLocalTime(&resultTz,                                           targetTimeZoneId,                                           srcTime,                                           srcTimeZoneId,                                           dstPolicy);    if (0 != rc) {        return rc;                                                    // RETURN    }    result->setDatetimeTz(resultTz);    result->setTimeZoneId(targetTimeZoneId);    return 0;}
开发者ID:SuperV1234,项目名称:bde,代码行数:26,


示例3: BSLS_ASSERT

void RbTreeUtil::swap(RbTreeAnchor *a, RbTreeAnchor *b){    BSLS_ASSERT(a);    BSLS_ASSERT(b);    RbTreeAnchor tmp(a->rootNode(),                     a->firstNode(),                     a->numNodes());    a->reset(b->rootNode(), b->firstNode(), b->numNodes());    b->reset(tmp.rootNode(), tmp.firstNode(), tmp.numNodes());    // Readjust the sentinel nodes of both trees.    if (0 == a->numNodes()) {        a->setFirstNode(a->sentinel());    }    else {        a->rootNode()->setParent(a->sentinel());    }    if (0 == b->numNodes()) {        b->setFirstNode(b->sentinel());    }    else {        b->rootNode()->setParent(b->sentinel());    }}
开发者ID:AlexTalks,项目名称:bde,代码行数:27,


示例4: BSLS_ASSERT

void String::toFixedLength(char       *dstString,                           int         dstLength,                           const char *srcString,                           int         srcLength,                           char        padChar){    BSLS_ASSERT(dstString);    BSLS_ASSERT(             0 <= dstLength);    BSLS_ASSERT(srcString || 0 == srcLength);    BSLS_ASSERT(             0 <= srcLength);    if (dstLength < srcLength) {        // We know 'srcLength > 0', therefore '0 != srcString'.        if (dstString != srcString) {            bsl::memmove(dstString, srcString, dstLength);        }    }    else {        if (srcString && dstString != srcString) {            bsl::memmove(dstString, srcString, srcLength);        }        for (int i = srcLength; i < dstLength; ++i) {            dstString[i] = padChar;        }    }}
开发者ID:SuperV1234,项目名称:bde,代码行数:27,


示例5: hash

staticunsigned int hash(const char *data, int length)    // That the memory starting at the specified 'data' of specified 'length'    // bytes in length.{    BSLS_ASSERT(0 <= length);    BSLS_ASSERT(data || 0 == length);    typedef unsigned char Ub1;    typedef unsigned int  Ub4;    const Ub1 *k    = reinterpret_cast<const Ub1 *>(data);    Ub4        hash = 0;    for (int i = 0; i < length; ++i) {        hash += k[i];        hash += (hash << 10);        hash ^= (hash >>  6);    }    hash += (hash <<  3);    hash ^= (hash >> 11);    hash += (hash << 15);    return hash;}
开发者ID:AlexTalks,项目名称:bde,代码行数:26,


示例6: lock

void bslmt::Sluice::wait(const void *token){    GenerationDescriptor *g =                static_cast<GenerationDescriptor *>(const_cast<void *>(token));    for (;;) {        g->d_sema.wait();        LockGuard<Mutex> lock(&d_mutex);        if (g->d_numSignaled) {            const int numSignaled = --g->d_numSignaled;            const int numThreads  = --g->d_numThreads;            BSLS_ASSERT(numThreads >= numSignaled);            BSLS_ASSERT(d_pendingGeneration != g);            if (0 == numThreads) {                // The last thread is responsible for cleanup.                BSLS_ASSERT(d_signaledGeneration != g);                g->d_next = d_descriptorPool;                d_descriptorPool = g;            }            return;                                                   // RETURN        }        // Spurious wakeups happen because 'timedWait' may timeout on the        // semaphore, but still consume a signal.    }}
开发者ID:SuperV1234,项目名称:bde,代码行数:31,


示例7: BSLS_ASSERT

int DecimalUtil::quantum(Decimal128 x){    BSLS_ASSERT(!isInf(x));    BSLS_ASSERT(!isNan(x));    return decQuadGetExponent(x.data());}
开发者ID:ychaim,项目名称:bde,代码行数:7,


示例8: BSLS_ASSERT

CountingAllocator::~CountingAllocator(){    BSLS_ASSERT(0               <= numBytesInUse());    BSLS_ASSERT(0               <= numBytesTotal());    BSLS_ASSERT(numBytesInUse() <= numBytesTotal());    BSLS_ASSERT(d_allocator_p);}
开发者ID:AlisdairM,项目名称:bde,代码行数:7,


示例9: lock

int TimeMetrics::percentage(int category){    bslmt::LockGuard<bslmt::Mutex> lock(&d_dataLock);    int result = 0;    BSLS_ASSERT(0 <= category);    BSLS_ASSERT(category < (int) d_categoryTimes.size());    bsls::TimeInterval now = bdlt::CurrentTime::now();    bsls::TimeInterval delta = now - d_categoryStartTimes[d_currentCategory];    int deltaMS = static_cast<int>(delta.seconds() * 1000 +                                              delta.nanoseconds() / k_MILLION);    d_categoryTimes[d_currentCategory] += deltaMS;    d_currentTotal += deltaMS;    d_categoryStartTimes[d_currentCategory] = now;    if (d_currentTotal) {        result = static_cast<int>(                           d_categoryTimes[category] * 100.0 / d_currentTotal);    }    return result < 0           ? 0           : result > 100             ? 100             : result;}
开发者ID:SuperV1234,项目名称:bde,代码行数:31,


示例10: BSLS_ASSERT

TimeMetrics::~TimeMetrics(){    BSLS_ASSERT(d_categoryStartTimes.size() == d_categoryTimes.size());    BSLS_ASSERT(d_currentCategory <                                static_cast<int>(d_categoryStartTimes.size()));    BSLS_ASSERT(0 <= d_currentCategory);}
开发者ID:SuperV1234,项目名称:bde,代码行数:7,


示例11: BSLS_ASSERT

// MANIPULATORSvoid *BlockList::allocate(int size){    BSLS_ASSERT(0 <= size);    if (0 == size) {        return 0;                                                     // RETURN    }    size = alignedAllocationSize(size, sizeof(Block));    Block *block = (Block *)d_allocator_p->allocate(size);    BSLS_ASSERT(0 == bsls::AlignmentUtil::calculateAlignmentOffset(                    (void *)block,                    bsls::AlignmentUtil::BSLS_MAX_ALIGNMENT));    block->d_next_p       = (Block *)d_head_p;    block->d_addrPrevNext = (Block **)&d_head_p;    if (d_head_p) {        d_head_p->d_addrPrevNext = &block->d_next_p;    }    d_head_p = block;    BSLS_ASSERT(0 == bsls::AlignmentUtil::calculateAlignmentOffset(                    (void *)&block->d_memory,                    bsls::AlignmentUtil::BSLS_MAX_ALIGNMENT));    return (void *)&block->d_memory;}
开发者ID:SuperV1234,项目名称:bde,代码行数:30,


示例12: BSLS_ASSERT

void TimeInterval::addInterval(bsls::Types::Int64 seconds,                               int                nanoseconds){    BSLS_ASSERT(isSumValidInt64(d_seconds, seconds));    BSLS_ASSERT(isSumValidInt64(       d_seconds + seconds,       (static_cast<bsls::Types::Int64>(d_nanoseconds) + nanoseconds) /                                                          k_NANOSECS_PER_SEC));    d_seconds += seconds;    bsls::Types::Int64 nanosecs = static_cast<bsls::Types::Int64>(nanoseconds)                                + d_nanoseconds;    if (nanosecs >=  k_NANOSECS_PER_SEC     || nanosecs <= -k_NANOSECS_PER_SEC) {        d_seconds     +=                  nanosecs / k_NANOSECS_PER_SEC;        d_nanoseconds  = static_cast<int>(nanosecs % k_NANOSECS_PER_SEC);    }    else {        d_nanoseconds = static_cast<int>(nanosecs);    }    if (d_seconds > 0 && d_nanoseconds < 0) {        --d_seconds;        d_nanoseconds += k_NANOSECS_PER_SEC;    }    else if (d_seconds < 0 && d_nanoseconds > 0) {        ++d_seconds;        d_nanoseconds -= k_NANOSECS_PER_SEC;    }}
开发者ID:AlisdairM,项目名称:bde,代码行数:31,


示例13: BSLS_ASSERT

void TcpConnector::deallocate(btlsc::Channel *channel){    BSLS_ASSERT(channel);    char *arena = (char *) channel;    TcpTimedChannel *c =        dynamic_cast<TcpTimedChannel*>(channel);    btlso::StreamSocket<btlso::IPv4Address> *s = NULL;    if (c) {        s = c->socket();    }    else {        TcpChannel *c =            dynamic_cast<TcpChannel*>(channel);        BSLS_ASSERT(c);        s = c->socket();    }    BSLS_ASSERT(s);    channel->invalidate();    d_factory_p->deallocate(s);    bsl::vector<btlsc::Channel*>::iterator idx =               bsl::lower_bound(d_channels.begin(), d_channels.end(), channel);    BSLS_ASSERT(idx != d_channels.end() && *idx == channel);    d_channels.erase(idx);    d_pool.deallocate(arena);    return ;}
开发者ID:peteware,项目名称:bde,代码行数:30,


示例14: BSLS_ASSERT

int btlso::SocketImpUtil::write(const btlso::SocketHandle::Handle&  socket,                                const void                         *buffer,                                int                                 numBytes,                                int                                *errorCode){    // Implementation notes: For non blocking IO, the send operation will write    // out some or all of the buffer if possible.  However, since the    // implementation of sockets may include internal buffers of certain sizes    // and optimizations, the send function may return a "would block" error or    // an smaller than expected number of bytes written even if it appears as    // if the internal socket buffer has more room.  This is known as the low    // water mark and may be implemented even if the equivalent socket option    // is not available.  For the blocking IO case, the send operation may    // block until all or part of the data is written.  No assumption should be    // made regarding the number of bytes that will be written with a single    // call.    int rc;    BSLS_ASSERT(buffer);    BSLS_ASSERT(numBytes >= 0);    rc = ::send(socket, static_cast<const char *>(buffer), numBytes, 0);    int errorNumber = rc >= 0 ? 0 : SocketImpUtil_Util::getErrorCode();    if (errorNumber && errorCode) {        *errorCode = errorNumber;    }    return errorNumber ? SocketImpUtil_Util::mapErrorCode(errorNumber) : rc;}
开发者ID:SuperV1234,项目名称:bde,代码行数:30,


示例15: d_mutex

// CREATORSChannelPoolChannel::ChannelPoolChannel(                             int                             channelId,                             ChannelPool                    *channelPool,                             btlb::BlobBufferFactory        *blobBufferFactory,                             bdlma::ConcurrentPoolAllocator *spAllocator,                             bslma::Allocator               *basicAllocator): d_mutex(), d_callbackInProgress(false), d_closed(false), d_readQueue(basicAllocator), d_blobBufferFactory_p(blobBufferFactory,                        0,                        &bslma::ManagedPtrUtil::noOpDeleter), d_spAllocator_p(spAllocator), d_channelPool_p(channelPool), d_nextClockId(channelId + 0x00800000), d_channelId(channelId), d_peerAddress(), d_localAddress(), d_allocator_p(bslma::Default::allocator(basicAllocator)){    BSLS_ASSERT(0 != channelPool);    BSLS_ASSERT(0 != blobBufferFactory);    BSLS_ASSERT(0 != spAllocator);    // Queue these addresses since the ChannelPool channel can have    // disappeared when we get SESSION_DOWN.    d_channelPool_p->getLocalAddress(&d_localAddress, d_channelId);    d_channelPool_p->getPeerAddress(&d_peerAddress, d_channelId);}
开发者ID:AlisdairM,项目名称:bde,代码行数:32,


示例16: BSLS_ASSERT

double PeriodDayCountUtil::yearsDiff(                                 const bdlt::Date&              beginDate,                                 const bdlt::Date&              endDate,                                 const bsl::vector<bdlt::Date>& periodDate,                                 double                         periodYearDiff,                                 DayCountConvention::Enum       convention){    BSLS_ASSERT(periodDate.size() >= 2);    BSLS_ASSERT(periodDate.front() <= beginDate);    BSLS_ASSERT(                      beginDate <= periodDate.back());    BSLS_ASSERT(periodDate.front() <= endDate);    BSLS_ASSERT(                      endDate   <= periodDate.back());    BSLS_ASSERT_SAFE(isSortedAndUnique(periodDate.begin(), periodDate.end()));    double numYears;    switch (convention) {      case DayCountConvention::e_PERIOD_ICMA_ACTUAL_ACTUAL: {        numYears = bbldc::PeriodIcmaActualActual::yearsDiff(beginDate,                                                            endDate,                                                            periodDate,                                                            periodYearDiff);      } break;      default: {        BSLS_ASSERT_OPT(0 && "Unrecognized convention");        numYears = 0.0;      } break;    }    return numYears;}
开发者ID:SuperV1234,项目名称:bde,代码行数:32,


示例17: BSLS_ASSERT

int baltzo::TimeZoneUtilImp::initLocalTime(                                       bdlt::DatetimeTz        *result,                                       LocalTimeValidity::Enum *resultValidity,                                       const bdlt::Datetime&    localTime,                                       const char              *timeZoneId,                                       DstPolicy::Enum          dstPolicy,                                       ZoneinfoCache           *cache){    BSLS_ASSERT(result);    BSLS_ASSERT(resultValidity);    BSLS_ASSERT(timeZoneId);    BSLS_ASSERT(cache);    const Zoneinfo *timeZone;    const int rc = lookupTimeZone(&timeZone, timeZoneId, cache);    if (0 != rc) {        return rc;                                                    // RETURN    }    Zoneinfo::TransitionConstIterator iter;    resolveLocalTime(result,                     resultValidity,                     &iter,                     localTime,                     dstPolicy,                     *timeZone);    return 0;}
开发者ID:SuperV1234,项目名称:bde,代码行数:28,


示例18: lookupTimeZone

// STATIC HELPER FUNCTIONSstaticint lookupTimeZone(const baltzo::Zoneinfo **timeZone,                   const char              *timeZoneId,                   baltzo::ZoneinfoCache   *cache)    // Load, into the specified 'timeZone', the address of the time zone    // information having the specified 'timeZoneId' from the specified    // 'cache'.  Return 0 on success, and a non-zero value otherwise.  A return    // status of 'baltzo::ErrorCode::k_UNSUPPORTED_ID' indicates that    // 'timeZoneId' is not recognized.{    BSLS_ASSERT(timeZone);    BSLS_ASSERT(timeZoneId);    BSLS_ASSERT(cache);    int rc = 0;    *timeZone = cache->getZoneinfo(&rc, timeZoneId);    BSLS_ASSERT((0 == rc && 0 != *timeZone) || (0 != rc && 0 == *timeZone));    if (0 == *timeZone) {        BALL_LOG_SET_CATEGORY(LOG_CATEGORY);        BALL_LOG_INFO << "No data found for time zone '" << timeZoneId                      << "' (rc = " << rc << ")." << BALL_LOG_END;    }    return rc;}
开发者ID:SuperV1234,项目名称:bde,代码行数:27,


示例19: reverse_hash

staticunsigned int reverse_hash(const char *data, int length)    // That the memory starting at the specified 'data' of specified 'length'    // bytes in length.  Do the bytes in the reverse of the order that 'hash'    // would do them, so that this function, when called on a little-endian    // machine, will return the same value as 'hash' called on a big-endian    // machine.{    BSLS_ASSERT(0 <= length);    BSLS_ASSERT(data || 0 == length);    typedef unsigned char Ub1;    typedef unsigned int  Ub4;    const Ub1 *k    = reinterpret_cast<const Ub1 *>(data);    Ub4        hash = 0;    for (int i = length; i > 0; ) {        hash += k[--i];        hash += (hash << 10);        hash ^= (hash >>  6);    }    hash += (hash <<  3);    hash ^= (hash >> 11);    hash += (hash << 15);    return hash;}
开发者ID:AlexTalks,项目名称:bde,代码行数:29,


示例20: BSLS_ASSERT

// MANIPULATORSvoid Throttle::initialize(int                         maxSimultaneousActions,                          Int64                       nanosecondsPerAction,                          bsls::SystemClockType::Enum clockType){    BSLS_ASSERT(0 <= maxSimultaneousActions);    BSLS_ASSERT(0 <= nanosecondsPerAction);    BSLS_ASSERT(maxSimultaneousActions || nanosecondsPerAction);    BSLS_ASSERT(LLONG_MAX / bsl::max(maxSimultaneousActions, 1) >=                                                     nanosecondsPerAction);    BSLS_ASSERT(bsls::SystemClockType::e_MONOTONIC == clockType ||                bsls::SystemClockType::e_REALTIME  == clockType);    AtomicOps::setInt64(&d_prevLeakTime, -k_TEN_YEARS_NANOSECONDS);    if (0 == maxSimultaneousActions) {        d_nanosecondsPerAction = k_ALLOW_NONE;    }    else if (0 == nanosecondsPerAction) {        d_nanosecondsPerAction = k_ALLOW_ALL;    }    else {        d_nanosecondsPerAction = nanosecondsPerAction;    }    // If 'd_nanosecondsPerAction' is set to 'allow all' or 'allow none', then    // it doesn't matter what 'd_nanosecondsPerTotalReset' is.    d_nanosecondsPerTotalReset = maxSimultaneousActions * nanosecondsPerAction;    d_maxSimultaneousActions   = 0 == nanosecondsPerAction                               ? INT_MAX                               : maxSimultaneousActions;    d_clockType = clockType;}
开发者ID:peteware,项目名称:bde,代码行数:34,


示例21: BSLS_ASSERT

void *BufferImpUtil::allocateFromBufferRaw(int                       *cursor,                                           char                      *buffer,                                           int                        size,                                           bsls::Alignment::Strategy  strategy){    BSLS_ASSERT(cursor);    BSLS_ASSERT(buffer);    BSLS_ASSERT(0 < size);    BSLS_ASSERT(0 <= *cursor);    void *result = 0;    switch (strategy) {      case bsls::Alignment::BSLS_MAXIMUM: {        result = BufferImpUtil::allocateMaximallyAlignedFromBufferRaw(cursor,                                                                      buffer,                                                                      size);      } break;      case bsls::Alignment::BSLS_NATURAL: {        result = BufferImpUtil::allocateNaturallyAlignedFromBufferRaw(cursor,                                                                      buffer,                                                                      size);      } break;      case bsls::Alignment::BSLS_BYTEALIGNED: {        result = BufferImpUtil::allocateOneByteAlignedFromBufferRaw(cursor,                                                                    buffer,                                                                    size);      } break;      default: {        BSLS_ASSERT_OPT(0 && "Invalid alignment 'strategy' value.");      } break;    }    return result;}
开发者ID:SuperV1234,项目名称:bde,代码行数:35,


示例22: d_magic

StackTraceTestAllocator::StackTraceTestAllocator(                                           int               numRecordedFrames,                                           bslma::Allocator *basicAllocator): d_magic(k_STACK_TRACE_TEST_ALLOCATOR_MAGIC), d_numBlocksInUse(0), d_blocks(0), d_mutex(), d_name("<unnamed>"), d_failureHandler(bsl::allocator_arg_t(),                   bsl::allocator<FailureHandler>(basicAllocator                                   ? basicAllocator                                   : &bslma::MallocFreeAllocator::singleton())), d_maxRecordedFrames(numRecordedFrames + k_IGNORE_FRAMES), d_traceBufferLength(getTraceBufferLength(numRecordedFrames)), d_ostream(&bsl::cerr), d_demangleFlag(true), d_allocator_p(basicAllocator ? basicAllocator                               : &bslma::MallocFreeAllocator::singleton()){    BSLS_ASSERT_OPT(numRecordedFrames >= 2);    BSLS_ASSERT(d_maxRecordedFrames >= numRecordedFrames);    BSLS_ASSERT(d_traceBufferLength >= d_maxRecordedFrames);    // This must be assigned in a statement in the body of the c'tor rather    // than in the initializer list to work around a microsoft bug with    // function pointers.    d_failureHandler = &failAbort;}
开发者ID:bloomberg,项目名称:bde,代码行数:29,



注:本文中的BSLS_ASSERT函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ BSON函数代码示例
C++ BRect函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。