当前位置: 首页>>代码示例>>C++>>正文


C++ optional::reset方法代码示例

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


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

示例1: send_bad_response

    void send_bad_response(
        http::status status,
        std::string const& error)
    {
        string_response_.emplace(
            std::piecewise_construct,
            std::make_tuple(),
            std::make_tuple(alloc_));

        string_response_->result(status);
        string_response_->keep_alive(false);
        string_response_->set(http::field::server, "Beast");
        string_response_->set(http::field::content_type, "text/plain");
        string_response_->body() = error;
        string_response_->prepare_payload();

        string_serializer_.emplace(*string_response_);

        http::async_write(
            socket_,
            *string_serializer_,
            [this](boost::beast::error_code ec, std::size_t)
            {
                socket_.shutdown(tcp::socket::shutdown_send, ec);
                string_serializer_.reset();
                string_response_.reset();
                accept();
            });
    }
开发者ID:miguelportilla,项目名称:Beast,代码行数:29,代码来源:http_server_fast.cpp

示例2: operator

			data_type operator() (object_type *object, const std::string &title) {
				if (!data_) {
					data_type tmp;
					if (fetch_data(object, tmp, title))
						data_.reset(tmp);
					else
						data_.reset(traits::get_default());
				}
				return *data_;
			}
开发者ID:borgified,项目名称:nscp,代码行数:10,代码来源:filter.hpp

示例3: send_file

    void send_file(boost::beast::string_view target)
    {
        // Request path must be absolute and not contain "..".
        if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos)
        {
            send_bad_response(
                http::status::not_found,
                "File not found\r\n");
            return;
        }

        std::string full_path = doc_root_;
        full_path.append(
            target.data(),
            target.size());

        http::file_body::value_type file;
        boost::beast::error_code ec;
        file.open(
            full_path.c_str(),
            boost::beast::file_mode::read,
            ec);
        if(ec)
        {
            send_bad_response(
                http::status::not_found,
                "File not found\r\n");
            return;
        }

        file_response_.emplace(
            std::piecewise_construct,
            std::make_tuple(),
            std::make_tuple(alloc_));

        file_response_->result(http::status::ok);
        file_response_->keep_alive(false);
        file_response_->set(http::field::server, "Beast");
        file_response_->set(http::field::content_type, mime_type(target.to_string()));
        file_response_->body() = std::move(file);
        file_response_->prepare_payload();

        file_serializer_.emplace(*file_response_);

        http::async_write(
            socket_,
            *file_serializer_,
            [this](boost::beast::error_code ec, std::size_t)
            {
                socket_.shutdown(tcp::socket::shutdown_send, ec);
                file_serializer_.reset();
                file_response_.reset();
                accept();
            });
    }
开发者ID:miguelportilla,项目名称:Beast,代码行数:55,代码来源:http_server_fast.cpp

示例4: SetLuaBatchThread

	void SetLuaBatchThread(bool set) {
		if (set) {
			luaBatchThreadID = Threading::GetCurrentThreadId();
		} else {
			luaBatchThreadID.reset();
		}
	}
开发者ID:9heart,项目名称:spring,代码行数:7,代码来源:Threading.cpp

示例5: handle_move_to

static bool handle_move_to()
{
    while( input->ready() || ( std::cin.good() && !std::cin.eof() ) )
    {
        if( differential )
        {
            const position* position = input->read();
            if( !position ) { return true; }
            return handle_move_to< quickset::ptcr::commands::move_to_delta >( *position );
        }
        else
        {
            if( !target )
            {
                const position* position = input->read();
                if( !position ) { return true; }
                target = *position;
            }
            if( !handle_move_to< quickset::ptcr::commands::move_to >( *target ) ) { return false; }
            target.reset();
            return true;
        }
    }
    return true;
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例6: SetSimThread

	void SetSimThread(bool set) {
		if (set) {
			simThreadID = Threading::GetCurrentThreadId();
			luaBatchThreadID = simThreadID;
		} else {
			simThreadID.reset();
		}
	}
开发者ID:9heart,项目名称:spring,代码行数:8,代码来源:Threading.cpp

示例7: preconditions_hold_put_

  // utility functions; require a lock to already be taken
  // and the container to already be full/empty as applicable.
  // Use these functions everywhere that modifies contents_.
  void preconditions_hold_put_(value_type const& v) {
    if(LASERCAKE_NO_THREADS) {
      caller_error_if(contents_, "'put' into a full m_var in single-threaded mode blocks.");
    }
    contents_.reset(v);
#if !LASERCAKE_NO_THREADS
    readers_wait_on_.notify_one();
#endif
  }
开发者ID:Lasercake,项目名称:Lasercake,代码行数:12,代码来源:concurrency_utils.hpp

示例8: get

    void                get( cstring string_id, boost::optional<T>& res ) const
    {
        const_argument_ptr arg = (*this)[string_id];

        if( arg )
            res = arg_value<T>( *arg );
        else
            res.reset();
    }
开发者ID:jacob-meacham,项目名称:Ego,代码行数:9,代码来源:parser.hpp

示例9: preconditions_hold_take_

  value_type preconditions_hold_take_() {
    if(LASERCAKE_NO_THREADS) {
      caller_error_if(!contents_, "'take' from an empty m_var in single-threaded mode blocks.");
    }
    value_type result = contents_.get();
    contents_.reset();
#if !LASERCAKE_NO_THREADS
    writers_wait_on_.notify_one();
#endif
    return result;
  }
开发者ID:Lasercake,项目名称:Lasercake,代码行数:11,代码来源:concurrency_utils.hpp

示例10: if

 static inline void to_ds_type(mapnik::geometry_container const& paths,
                 boost::optional<mapnik::datasource::geometry_t> & result)
 {
     if (paths.size() == 1)
     {
         result.reset(static_cast<mapnik::datasource::geometry_t>(paths.front().type()));
     }
     else if (paths.size() > 1)
     {
         int multi_type = 0;
         for (auto const& geom : paths)
         {
             int type = static_cast<int>(geom.type());
             if (multi_type > 0 && multi_type != type)
             {
                 result.reset(datasource::Collection);
             }
             multi_type = type;
             result.reset(static_cast<mapnik::datasource::geometry_t>(type));
         }
     }
 }
开发者ID:Andrey-VI,项目名称:mapnik,代码行数:22,代码来源:geometry_to_ds_type.hpp

示例11: load

void load(
    Archive & ar, 
    boost::optional<T> & t, 
    const unsigned int /*version*/
){
    bool tflag;
    ar >> boost::serialization::make_nvp("initialized", tflag);
    if (tflag){
        stack_construct<Archive, T> aux(ar);
        ar >> boost::serialization::make_nvp("value", aux.reference());
        t.reset(aux.reference());
    }
    else {
开发者ID:rzymek,项目名称:cxxsp,代码行数:13,代码来源:optional.hpp

示例12: frame

    virtual void onFrame        (const Leap::Controller&)
    {
        const Leap::Frame frame(m_Controller.frame(0));
        const Leap::Hand hand(frame.hands().rightmost());
        if (!hand.isValid())
        {
            m_LastNormalizedPos.reset();
            return;
        }

        const Leap::Vector pos(hand.palmPosition());
        m_LastNormalizedPos = frame.interactionBox().normalizePoint(pos);
    }
开发者ID:IrmatDen,项目名称:sfge,代码行数:13,代码来源:controller_leap_metalpad.cpp

示例13: read_block_impl_

static block_t* read_block_impl_( ::tbb::flow_control* flow = NULL )
{
    static boost::array< block_t, 3 > blocks;
    static boost::optional< block_t::pair_t > last;
    static comma::uint32 block_id = 0;
    block_t::pairs_t* points = new block_t::pairs_t;
    while( true ) // quick and dirty, only if --discard
    {
        static comma::csv::input_stream< input_t > istream( std::cin, csv );
        points->clear();
        while( true )
        {
            if( last )
            {
                block_id = last->first.block;
                points->push_back( *last );
                last.reset();
            }
            if( is_shutdown || std::cout.bad() || std::cin.bad() || std::cin.eof() )
            {
                if( bursty_reader ) { bursty_reader->stop(); } // quick and dirty, it sucks...
                if( flow ) { flow->stop(); }
                break;
            }
            const input_t* p = istream.read();
            if( !p ) { break; }
            std::string line;
            if( csv.binary() )
            {
                line.resize( csv.format().size() );
                ::memcpy( &line[0], istream.binary().last(), csv.format().size() );
            }
            else
            {
                line = comma::join( istream.ascii().last(), csv.delimiter );
            }
            last = std::make_pair( *p, line );
            if( p->block != block_id ) { break; }
        }
        for( unsigned int i = 0; i < blocks.size(); ++i )
        {
            if( !blocks[i].empty ) { continue; }
            blocks[i].clear();
            blocks[i].id = block_id;
            blocks[i].points.reset( points );
            blocks[i].empty = false;
            return &blocks[i];
        }
    }
}
开发者ID:acfr,项目名称:snark,代码行数:50,代码来源:points-foreground-partitions.cpp

示例14: to_ds_type

 void to_ds_type(mapnik::geometry_container const& paths,
                 boost::optional<mapnik::datasource::geometry_t> & result)
 {
     if (paths.size() == 1)
     {
         result.reset(static_cast<mapnik::datasource::geometry_t>(paths.front().type()));
     }
     else if (paths.size() > 1)
     {
         int multi_type = 0;
         geometry_container::const_iterator itr = paths.begin();
         geometry_container::const_iterator end = paths.end();
         for ( ; itr!=end; ++itr)
         {
             int type = static_cast<int>(itr->type());
             if (multi_type > 0 && multi_type != type)
             {
                 result.reset(datasource::Collection);
             }
             multi_type = type;
             result.reset(static_cast<mapnik::datasource::geometry_t>(type));
         }
     }
 }
开发者ID:novldp,项目名称:mapnik,代码行数:24,代码来源:geometry_to_ds_type.hpp

示例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){
        unsigned int v = 0;
        if(3 < ar.get_library_version()){
            ar >> boost::serialization::make_nvp("item_version", v);
        }
        detail::stack_construct<Archive, T> aux(ar, v);
        ar >> boost::serialization::make_nvp("value", aux.reference());
        t.reset(aux.reference());
    }
开发者ID:JupiterSmalltalk,项目名称:openqwaq,代码行数:16,代码来源:optional.hpp


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