本文整理汇总了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();
});
}
示例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_;
}
示例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();
});
}
示例4: SetLuaBatchThread
void SetLuaBatchThread(bool set) {
if (set) {
luaBatchThreadID = Threading::GetCurrentThreadId();
} else {
luaBatchThreadID.reset();
}
}
示例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;
}
示例6: SetSimThread
void SetSimThread(bool set) {
if (set) {
simThreadID = Threading::GetCurrentThreadId();
luaBatchThreadID = simThreadID;
} else {
simThreadID.reset();
}
}
示例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
}
示例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();
}
示例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;
}
示例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));
}
}
}
示例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 {
示例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);
}
示例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];
}
}
}
示例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));
}
}
}
示例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());
}