• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ boost::optional类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: NetworkImagingRemoteHandler

 NetworkImagingRemoteHandler(vrpn_ConnectionPtr const &conn,
                             std::string const &deviceName,
                             boost::optional<OSVR_ChannelCount> sensor,
                             common::InterfaceList &ifaces)
     : m_dev(common::createClientDevice(deviceName, conn)),
       m_interfaces(ifaces), m_all(!sensor.is_initialized()),
       m_sensor(sensor) {
     auto imaging = common::ImagingComponent::create();
     m_dev->addComponent(imaging);
     imaging->registerImageHandler(
         [&](common::ImageData const &data,
             util::time::TimeValue const &timestamp) {
             m_handleImage(data, timestamp);
         });
     OSVR_DEV_VERBOSE("Constructed an ImagingHandler for "
                      << deviceName);
 }
开发者ID:jimbo00000,项目名称:OSVR-Core,代码行数:17,代码来源:ImagingRemoteFactory.cpp


示例2: evaluate

    /**
     * This method evaluates the path at a given time and returns the target
     * position and velocity of the robot.
     *
     * @param t Time (in seconds) since the robot started the path. Throws an
     *     exception if t<0
     * @return A MotionInstant containing the position and velocity at the given
     *     time if @t is within the range of the path.  If @t is not within the
     *     time range of this path, this method returns boost::none.
     */
    virtual boost::optional<RobotInstant> evaluate(
        RJ::Seconds t) const override {
        if (!path) {
            return boost::none;
        }

        boost::optional<RobotInstant> instant = path->evaluate(t);
        if (!angleFunction) {
            return instant;
        } else {
            if (instant) {
                instant->angle = angleFunction->operator()(instant->motion);
                return instant;
            } else {
                return boost::none;
            }
        }
    }
开发者ID:echin98,项目名称:robocup-software,代码行数:28,代码来源:Path.hpp


示例3: parse_bbox

osmium::Box parse_osmium_t::parse_bbox(const boost::optional<std::string> &bbox)
{
    double minx, maxx, miny, maxy;
    int n = sscanf(bbox->c_str(), "%lf,%lf,%lf,%lf",
                   &minx, &miny, &maxx, &maxy);
    if (n != 4)
        throw std::runtime_error("Bounding box must be specified like: minlon,minlat,maxlon,maxlat\n");

    if (maxx <= minx)
        throw std::runtime_error("Bounding box failed due to maxlon <= minlon\n");

    if (maxy <= miny)
        throw std::runtime_error("Bounding box failed due to maxlat <= minlat\n");

    fprintf(stderr, "Applying Bounding box: %f,%f to %f,%f\n", minx, miny, maxx, maxy);

    return osmium::Box(minx, miny, maxx, maxy);
}
开发者ID:tomhughes,项目名称:osm2pgsql,代码行数:18,代码来源:parse-osmium.cpp


示例4: installNewBattleInterface

void CClient::installNewBattleInterface(std::shared_ptr<CBattleGameInterface> battleInterface, boost::optional<PlayerColor> color, bool needCallback)
{
	boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim);
	PlayerColor colorUsed = color.get_value_or(PlayerColor::UNFLAGGABLE);

	if(!color)
		privilegedBattleEventReceivers.push_back(battleInterface);

	battleints[colorUsed] = battleInterface;

	if(needCallback)
	{
		logGlobal->trace("\tInitializing the battle interface for player %s", *color);
		auto cbc = std::make_shared<CBattleCallback>(color, this);
		battleCallbacks[colorUsed] = cbc;
		battleInterface->init(cbc);
	}
}
开发者ID:vcmi,项目名称:vcmi,代码行数:18,代码来源:Client.cpp


示例5: installNewPlayerInterface

void CClient::installNewPlayerInterface(std::shared_ptr<CGameInterface> gameInterface, boost::optional<PlayerColor> color, bool battlecb)
{
	boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim);
	PlayerColor colorUsed = color.get_value_or(PlayerColor::UNFLAGGABLE);

	if(!color)
		privilegedGameEventReceivers.push_back(gameInterface);

	playerint[colorUsed] = gameInterface;

	logGlobal->trace("\tInitializing the interface for player %s", colorUsed);
	auto cb = std::make_shared<CCallback>(gs, color, this);
	callbacks[colorUsed] = cb;
	battleCallbacks[colorUsed] = cb;
	gameInterface->init(cb);

	installNewBattleInterface(gameInterface, color, battlecb);
}
开发者ID:vcmi,项目名称:vcmi,代码行数:18,代码来源:Client.cpp


示例6: transactionFromSQL

Transaction::pointer Transaction::transactionFromSQL (
    boost::optional<std::uint64_t> const& ledgerSeq,
    boost::optional<std::string> const& status,
    Blob const& rawTxn,
    Validate validate)
{
    std::uint32_t const inLedger =
        rangeCheckedCast<std::uint32_t>(ledgerSeq.value_or (0));

    SerialIter it (makeSlice(rawTxn));
    auto txn = std::make_shared<STTx> (it);
    std::string reason;
    auto tr = std::make_shared<Transaction> (txn, validate, reason);

    tr->setStatus (sqlTransactionStatus (status));
    tr->setLedger (inLedger);
    return tr;
}
开发者ID:referjs,项目名称:rippled,代码行数:18,代码来源:Transaction.cpp


示例7: add

/**
 * Add a new entry in the Link Responde Pool.
 *
 * @param user MIH source identifier.
 * @param tid The transaction identifier.
 * @param link_scan_rsp_list The link scan response list.
 * @param link_ac_result The link action result
 */
void link_response_pool::add(mih::octet_string user,
                             uint16 tid,
                             boost::optional<mih::link_scan_rsp_list> link_scan_rsp_list,
                             mih::link_ac_result link_ac_result)
{
	pending_link_response p;

	p.user.assign(user);
	p.tid = tid;
	action ac;
	if(link_scan_rsp_list.is_initialized()) {
		ac.link_scan_rsp_list = link_scan_rsp_list;
	}
	ac.link_ac_result = link_ac_result;
	p.response = ac;

	boost::mutex::scoped_lock lock(_mutex);
	_cpool.push_back(p);
}
开发者ID:ATNoG,项目名称:EMICOM,代码行数:27,代码来源:link_response_pool.cpp


示例8: setPeopleperSpaceFloorArea

 bool PeopleDefinition_Impl::setPeopleperSpaceFloorArea(boost::optional<double> peopleperSpaceFloorArea) {
   bool result = false;
   if (peopleperSpaceFloorArea) {
     result = setDouble(OS_People_DefinitionFields::PeopleperSpaceFloorArea,peopleperSpaceFloorArea.get());
     if (result) {
       result = setString(OS_People_DefinitionFields::NumberofPeopleCalculationMethod, "People/Area");
       OS_ASSERT(result);
       result = setString(OS_People_DefinitionFields::NumberofPeople, "");
       OS_ASSERT(result);
       result = setString(OS_People_DefinitionFields::SpaceFloorAreaperPerson, "");
       OS_ASSERT(result);                
     }      
   } else {
     if (istringEqual("People/Area", this->numberofPeopleCalculationMethod())){
       result = setDouble(OS_People_DefinitionFields::PeopleperSpaceFloorArea, 0.0);
     }
   }
   return result;
 }
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:19,代码来源:PeopleDefinition.cpp


示例9: setSpaceFloorAreaperPerson

 bool PeopleDefinition_Impl::setSpaceFloorAreaperPerson(boost::optional<double> spaceFloorAreaperPerson) {
   bool result(false);
   if (spaceFloorAreaperPerson) {
     result = setDouble(OS_People_DefinitionFields::SpaceFloorAreaperPerson,spaceFloorAreaperPerson.get());
     if (result) {
       result = setString(OS_People_DefinitionFields::NumberofPeopleCalculationMethod, "Area/Person");
       OS_ASSERT(result);
       result = setString(OS_People_DefinitionFields::NumberofPeople, "");
       OS_ASSERT(result);
       result = setString(OS_People_DefinitionFields::PeopleperSpaceFloorArea, "");
       OS_ASSERT(result);      
     }
   } else {
     if (istringEqual("Area/Person", this->numberofPeopleCalculationMethod())){
       result = setDouble(OS_People_DefinitionFields::SpaceFloorAreaperPerson, 0.0);
     }
   }
   return result;
 }
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:19,代码来源:PeopleDefinition.cpp


示例10: appendAsCommand

void CommitChunkMigrationRequest::appendAsCommand(
    BSONObjBuilder* builder,
    const NamespaceString& nss,
    const ShardId& fromShard,
    const ShardId& toShard,
    const ChunkType& migratedChunkType,
    const boost::optional<ChunkType>& controlChunkType) {
    invariant(builder->asTempObj().isEmpty());
    invariant(nss.isValid());

    builder->append(kConfigSvrCommitChunkMigration, nss.ns());
    builder->append(kFromShard, fromShard.toString());
    builder->append(kToShard, toShard.toString());
    builder->append(kMigratedChunk, migratedChunkType.toBSON());

    if (controlChunkType) {
        builder->append(kControlChunk, controlChunkType->toBSON());
    }
}
开发者ID:ChineseDr,项目名称:mongo,代码行数:19,代码来源:commit_chunk_migration_request_type.cpp


示例11: createJacobianAssembler

std::unique_ptr<AbstractJacobianAssembler> createJacobianAssembler(
    boost::optional<BaseLib::ConfigTree> const& config)
{
    if (!config)
        return std::unique_ptr<AbstractJacobianAssembler>(
            new AnalyticalJacobianAssembler);

    //! \ogs_file_param{process__jacobian_assembler__type}
    auto const type = config->peekConfigParameter<std::string>("type");

    if (type == "Analytical") {
        config->ignoreConfigParameter("type");
        return std::unique_ptr<AbstractJacobianAssembler>(
            new AnalyticalJacobianAssembler);
    } else if (type == "CentralDifferences") {
        return createCentralDifferencesJacobianAssembler(*config);
    }

    OGS_FATAL("Unknown Jacobian assembler type: `%s'.", type.c_str());
}
开发者ID:,项目名称:,代码行数:20,代码来源:


示例12: display_template_info

void display_template_info(const Glib::RefPtr<Gst::PadTemplate> &tpl,
                           const Glib::RefPtr<Gtk::TreeStore> &model, const Gtk::TreeModelColumn<Glib::ustring> &col_name,
                           const Gtk::TreeModelColumn<Glib::ustring> &col_value, boost::optional<const Gtk::TreeModel::Row&> parent_row)
{
    Gtk::TreeRow row;
    if (parent_row)
    {
        row = APPEND_SUB_ROW(_("Template"), tpl->get_name_template(), parent_row.get());
    }
    else
    {
        row = *(model->append());
        row[col_name] = _("Template");
        row[col_value] = tpl->get_name_template();
    }
    APPEND_SUB_ROW(_("Presence"), get_presence_str(tpl->get_presence()), row);
    APPEND_SUB_ROW(_("Direction"), get_direction_str(tpl->get_direction()), row);
    row = APPEND_SUB_ROW("Caps", "", row);
    display_caps(tpl->get_caps(), model, col_name, col_value, row);
}
开发者ID:GNOME,项目名称:gst-debugger,代码行数:20,代码来源:ui_utils.cpp


示例13: dataFrameTest

  void dataFrameTest(IOBuf* body, uint32_t dataLen,
                     boost::optional<uint8_t> padLen) {
    uint32_t frameLen = uint32_t(dataLen);
    if (padLen) {
      frameLen += 1 + padLen.get();
    }
    if (frameLen > kMaxFramePayloadLength) {
      EXPECT_DEATH_NO_CORE(writeData(queue_, body->clone(), 1, padLen,
                                     false), ".*");
    } else {
      writeData(queue_, body->clone(), 1, padLen, false);

      FrameHeader outHeader;
      std::unique_ptr<IOBuf> outBuf;
      parse(&parseData, outHeader, outBuf);

      EXPECT_EQ(outBuf->moveToFbString(), body->moveToFbString());
    }
    queue_.move(); // reset everything
  }
开发者ID:ImportantProjects,项目名称:proxygen,代码行数:20,代码来源:HTTP2FramerTest.cpp


示例14:

Vector OrientedPlane3DirectionPrior::evaluateError(const OrientedPlane3& plane,
    boost::optional<Matrix&> H) const {

  if (H) {
    Matrix H_p;
    Unit3 n_hat_p = measured_p_.normal();
    Unit3 n_hat_q = plane.normal();
    Vector e = n_hat_p.error(n_hat_q, H_p);
    H->resize(2, 3);
    H->block<2, 2>(0, 0) << H_p;
    H->block<2, 1>(0, 2) << Matrix::Zero(2, 1);
    return e;
  } else {
    Unit3 n_hat_p = measured_p_.normal();
    Unit3 n_hat_q = plane.normal();
    Vector e = n_hat_p.error(n_hat_q);
    return e;
  }

}
开发者ID:exoter-rover,项目名称:slam-gtsam,代码行数:20,代码来源:OrientedPlane3Factor.cpp


示例15: load

void load(
    Archive & ar, 
    boost::optional< T > & t, 
    const unsigned int /*version*/
){
    bool tflag;
    ar >> boost::serialization::make_nvp("initialized", tflag);
    if (tflag){
        boost::serialization::item_version_type item_version(0);
        boost::archive::library_version_type library_version(
            ar.get_library_version()
        );
        if(boost::archive::library_version_type(3) < library_version){
            // item_version is handled as an attribute so it doesnt need an NVP
           ar >> BOOST_SERIALIZATION_NVP(item_version);
        }
        detail::stack_construct<Archive, T> aux(ar, item_version);
        ar >> boost::serialization::make_nvp("value", aux.reference());
        t.reset(aux.reference());
    }
开发者ID:CasparCG,项目名称:Client,代码行数:20,代码来源:optional.hpp


示例16: load

void load(
    Archive & ar,
    boost::optional< T > & t,
    const unsigned int version
){
    bool tflag;
    ar >> boost::serialization::make_nvp("initialized", tflag);
    if(! tflag){
        t.reset();
        return;
    }

    if(0 == version){
        boost::serialization::item_version_type item_version(0);
        boost::archive::library_version_type library_version(
            ar.get_library_version()
        );
        if(boost::archive::library_version_type(3) < library_version){
            ar >> BOOST_SERIALIZATION_NVP(item_version);
        }
开发者ID:AbhinavJain13,项目名称:turicreate,代码行数:20,代码来源:optional.hpp


示例17: readShardChunks

StatusWith<std::vector<ChunkType>> readShardChunks(OperationContext* opCtx,
                                                   const NamespaceString& nss,
                                                   const BSONObj& query,
                                                   const BSONObj& sort,
                                                   boost::optional<long long> limit,
                                                   const OID& epoch) {
    // Query to retrieve the chunks.
    Query fullQuery(query);
    fullQuery.sort(sort);

    try {
        DBDirectClient client(opCtx);

        std::string chunkMetadataNs = ChunkType::ShardNSPrefix + nss.ns();
        std::unique_ptr<DBClientCursor> cursor =
            client.query(chunkMetadataNs, fullQuery, limit.get_value_or(0));

        if (!cursor) {
            return {ErrorCodes::OperationFailed,
                    str::stream() << "Failed to establish a cursor for reading " << chunkMetadataNs
                                  << " from local storage"};
        }

        std::vector<ChunkType> chunks;
        while (cursor->more()) {
            BSONObj document = cursor->nextSafe().getOwned();
            auto statusWithChunk = ChunkType::fromShardBSON(document, epoch);
            if (!statusWithChunk.isOK()) {
                return {statusWithChunk.getStatus().code(),
                        str::stream() << "Failed to parse chunk '" << document.toString()
                                      << "' due to "
                                      << statusWithChunk.getStatus().reason()};
            }
            chunks.push_back(std::move(statusWithChunk.getValue()));
        }

        return chunks;
    } catch (const DBException& ex) {
        return ex.toStatus();
    }
}
开发者ID:bjori,项目名称:mongo,代码行数:41,代码来源:shard_metadata_util.cpp


示例18: UpdateTextureFilters

	// /////////////////////////////////////////////////////////////////
	//
	// /////////////////////////////////////////////////////////////////
	void TextureManager::UpdateTextureFilters(boost::optional<TextureFilterMode> oldMode)
	{
#ifdef GLEW_EXT_texture_filter_anisotropic
		GLfloat aniLevelVal(0.0f);

		if(m_currTexFilterMode == eAnisotropic)
		{
			aniLevelVal = InterpolateFloat(m_anisotropicLinearLevel, 0.0f, m_maxAnisotropicValue);
		}
#endif

        GF_CLEAR_GL_ERROR();
        
		for(ElementMap::iterator i = m_elementsMap.begin(), end = m_elementsMap.end(); i != end; ++i)
		{
			GLenum currTarget(((*i).second).m_glTarget);
			if(currTarget != GL_TEXTURE_RECTANGLE)
			{
				Bind(((*i).second).m_id, currTarget);
				glTexParameteri(currTarget, GL_TEXTURE_MIN_FILTER, m_currMinFilter);
                GF_CHECK_GL_ERROR_TRC("TextureManager::UpdateTextureFilters(): ");
				
                glTexParameteri(currTarget, GL_TEXTURE_MAG_FILTER, m_currMagFilter);
                GF_CHECK_GL_ERROR_TRC("TextureManager::UpdateTextureFilters(): ");
                
#ifdef GLEW_EXT_texture_filter_anisotropic
				if(m_currTexFilterMode == eAnisotropic)
				{
					glTexParameterf(currTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniLevelVal);
                    GF_CHECK_GL_ERROR_TRC("TextureManager::UpdateTextureFilters(): ");
				}
				else if(oldMode.is_initialized() && *oldMode == eAnisotropic)
				{
					// Turn down ani level if we are switching away from it.
					glTexParameterf(currTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, 0.0f);
                    GF_CHECK_GL_ERROR_TRC("TextureManager::UpdateTextureFilters(): ");
				}
#endif
			}
		}
	}
开发者ID:,项目名称:,代码行数:44,代码来源:


示例19: AddItem

bool CDocumentItemCollection::AddItem(CDocumentItemPtr item, boost::optional<size_t> position)
{
	bool result = true;
	if (position)
	{
		size_t pos = position.get();
		if (pos > m_items.size())
		{
			result = false;
		}
		else
		{
			m_items.emplace(m_items.begin() + pos, item);
		}
	}
	else
	{
		m_items.emplace_back(item);
	}
	return result;
}
开发者ID:AlK2x,项目名称:OOD,代码行数:21,代码来源:DocumentItemCollection.cpp


示例20: interpret_argument_value

inline bool
interpret_argument_value( cstring source, boost::optional<std::list<T> >& res, int )
{
    BOOST_RT_PARAM_TRACE( "In interpret_argument_value<std::list<T>>" );

    res = std::list<T>();

    while( !source.is_empty() ) {
        // !! should we use token_iterator
        cstring::iterator single_value_end = std::find( source.begin(), source.end(), BOOST_RT_PARAM_LITERAL( ',' ) );

        boost::optional<T> value;
        interpret_argument_value( cstring( source.begin(), single_value_end ), value, 0 );

        res->push_back( *value );

        source.trim_left( single_value_end + 1 );
    }

    return true;
}
开发者ID:TheRyaz,项目名称:c_reading,代码行数:21,代码来源:interpret_argument_value.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ boost::pool类代码示例发布时间:2022-05-31
下一篇:
C++ boost::mutex类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap