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


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

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


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

示例1: signed_by

 bool signed_by( const address& a ) {
    if( !available_address_sigs ) {
       available_address_sigs = std::map<address,public_key_type>();
       provided_address_sigs = std::map<address,public_key_type>();
       for( auto& item : available_keys ) {
        (*available_address_sigs)[ address(pts_address(item, false, 56) ) ] = item;
        (*available_address_sigs)[ address(pts_address(item, true, 56) ) ] = item;
        (*available_address_sigs)[ address(pts_address(item, false, 0) ) ] = item;
        (*available_address_sigs)[ address(pts_address(item, true, 0) ) ] = item;
        (*available_address_sigs)[ address(item) ] = item;
       }
       for( auto& item : provided_signatures ) {
        (*provided_address_sigs)[ address(pts_address(item.first, false, 56) ) ] = item.first;
        (*provided_address_sigs)[ address(pts_address(item.first, true, 56) ) ] = item.first;
        (*provided_address_sigs)[ address(pts_address(item.first, false, 0) ) ] = item.first;
        (*provided_address_sigs)[ address(pts_address(item.first, true, 0) ) ] = item.first;
        (*provided_address_sigs)[ address(item.first) ] = item.first;
       }
    }
    auto itr = provided_address_sigs->find(a);
    if( itr == provided_address_sigs->end() )
    {
       auto aitr = available_address_sigs->find(a);
       if( aitr != available_address_sigs->end() ) {
          auto pk = available_keys.find(aitr->second);
          if( pk != available_keys.end() )
             return provided_signatures[aitr->second] = true;
          return false;
       }
    }
    return provided_signatures[itr->second] = true;
 }
开发者ID:8001800,项目名称:graphene,代码行数:32,代码来源:transaction.cpp

示例2: print_type_die

void print_type_die(std::ostream &_s, iterator_df<dwarf::core::basic_die> die_iter, optional<type_set&> types) {
	if (!die_iter) return;
	
	// Special case root early: just print all children
	if (die_iter.tag_here() == 0) {
		auto children = die_iter.children_here();
		for (auto iter = children.first; iter != children.second; iter++) {
			 print_type_die(_s, iter.base(), types);
			_s << endl;
		}
		return;
	}
	
	srk31::indenting_newline_ostream s(_s);
	//	auto &die = *die_iter;
	auto name_ptr = die_iter.name_here();
	auto tag = string(DEFAULT_DWARF_SPEC.tag_lookup(die_iter.tag_here())); 
	if (tag.compare("(unknown tag)") == 0) {
		// Leave unknown tags as hex
		tag = to_hex(die_iter.tag_here());
	} else {
		tag = tag.substr(7, string::npos); // remove DW_TAG_
	}
	auto offset = die_iter.offset_here();

	/* Offset, tag, name, type */

	bool offset_printed = false;
	bool name_printed = false;
	bool type_printed = false;
	
	if (offset) {
		s << "@0x" << std::hex << offset << std::dec << " ";
		offset_printed = true;
	}
	
	s << tag;

	if (name_ptr) {
		s << " " << *name_ptr;
		name_printed = true;
	}
	
	auto attrs = die_iter.copy_attrs(die_iter.get_root());
	auto &root = die_iter.get_root();

	/* Convert the type offset into a name if possible. */
	/* Two types (ha) of die with type information:
	   with_type_describing_layout_die => variables, members, etc, things *with* a type
	   type_describing_subprogram_die => subprograms (functions etc) *returning* a thing with a type
	   type_chain_die => things which are types with a type, e.g. typedefs, pointers, arrays
	   (yes, you're right, I can't count)
	*/
	dwarf::core::iterator_df<dwarf::core::type_die> type_die;
	auto with_type_iter = die_iter.as_a<with_type_describing_layout_die>();
	auto returning_type_iter = die_iter.as_a<type_describing_subprogram_die>();
	auto type_chain_iter = die_iter.as_a<type_chain_die>();
	if (with_type_iter) type_die = with_type_iter->get_type();
	else if (returning_type_iter) type_die = returning_type_iter->get_type();
	else if (type_chain_iter) type_die = type_chain_iter->get_type();
	
	if (type_die) {
		 // Dedup
		 if (types) {
			  auto dedup_type_iter = types->find(type_die);
			  //assert(dedup_type_iter != types->end());
			  if (dedup_type_iter != types->end()) {
				   _debug_print_dedup(type_die, *dedup_type_iter);
				   type_die = *dedup_type_iter;
			  }
		 }
		 auto abstract_name = type_die.name_here();
		 // Concretify (traverse typedefs etc)
		 auto concrete_die = type_die->get_concrete_type(root);
		 // Also dedup that. Just in case.
		 if (concrete_die && types) {
			  auto concrete_die_iter = types->find(concrete_die);
			  //assert(concrete_die_iter != types->end());
			  if (concrete_die_iter != types->end()) {
				   _debug_print_dedup(concrete_die, *concrete_die_iter);
				   concrete_die = *concrete_die_iter;
			  }
		 }
		 auto concrete_name = concrete_die.name_here();
		 auto type_name = (concrete_name ? concrete_name : abstract_name);
		 if (type_name) {
			  _debug_print_print(name_ptr, offset, type_die, concrete_die);
			  s << " : " << *type_name;
		 } else {
			  auto type_offset = (concrete_die ? concrete_die.offset_here() : type_die.offset_here());
			  s << " : @" << to_hex(type_offset);
			  
			  if (types->find(type_die) == types->end() && types->find(concrete_die) == types->end()) {
				   cerr << endl << "WARNING: a type was called for that wasn't in types!" << endl << "abstract: ";
				   type_die.print_with_attrs(cerr, 0);
				   cerr << endl << "concrete: ";
				   concrete_die.print_with_attrs(cerr, 0);
				   cerr << endl << "context: ";
				   die_iter.print_with_attrs(cerr, 0);
				   cerr << endl << endl;
//.........这里部分代码省略.........
开发者ID:ojno,项目名称:dwarfidl,代码行数:101,代码来源:dwarfprint.cpp


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