本文整理汇总了C++中boost::make_optional方法的典型用法代码示例。如果您正苦于以下问题:C++ boost::make_optional方法的具体用法?C++ boost::make_optional怎么用?C++ boost::make_optional使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost
的用法示例。
在下文中一共展示了boost::make_optional方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
void test( T v, T w )
{
test2( make_optional(v), optional<T> ());
test2( make_optional(v), make_optional(w));
test2( optional<T> () , optional<T> ());
test2( optional<T> () , make_optional(w));
}
示例2: make_optional
/// \brief Generate a description of any problem that makes the specified crh_output_spec invalid
/// or none otherwise
///
/// \relates crh_output_spec
str_opt cath::rslv::get_invalid_description(const crh_output_spec &arg_output_spec ///< The crh_output_spec to query
) {
return make_optional(
means_output_trimmed_hits( arg_output_spec.get_boundary_output() ) && arg_output_spec.get_generate_html_output(),
"Cannot output trimmed boundaries in HTML output"s
);
}
示例3: result
/// \brief Generate a string describing the difference between the specified dssp_dupl_ress parsed from a DSSP file
/// and the specified bifur_hbond_list or return none if there isn't any difference
///
/// \relates dssp_dupl_res
str_opt cath::sec::difference_string(const dssp_dupl_res_vec &arg_dssp_dupl_res_vec, ///< A vector of dssp_dupl_res parsed from a DSSP file
const bifur_hbond_list &arg_bifur_hbond_list ///< The dssp_dupl_res_list to be compared to the dssp_dupl_res vector
) {
const auto num_dssp_dupl_res = arg_dssp_dupl_res_vec.size();
const auto arg_bifur_hbonds = arg_bifur_hbond_list.size();
const auto dssp_non_null_indices = copy_build<size_vec>(
irange( 0_z, num_dssp_dupl_res )
| filtered(
[&] (const size_t &x) {
return ! arg_dssp_dupl_res_vec[ x ].pdb_residue_name.is_null();
}
)
);
const size_t num_non_null_residues = dssp_non_null_indices.size();
const str_opt num_prob = make_optional(
( num_non_null_residues != arg_bifur_hbonds ),
"Number of (non-null) DSSP hbond residues ("
+ ::std::to_string( num_non_null_residues )
+ "), doesn't match the number of calculated hbond residues ("
+ ::std::to_string( arg_bifur_hbonds )
+ "). "
);
const auto normal_index_of_dssp_index = [&] () {
size_vec result( num_dssp_dupl_res, 0 );
for (const size_t &x : irange( 0_z, dssp_non_null_indices.size() ) ) {
result[ dssp_non_null_indices[ x ] ] = x;
}
return result;
}();
for (const size_t &index : irange( 0_z, min( num_dssp_dupl_res, arg_bifur_hbonds ) ) ) {
const auto diff_str = difference_string( arg_dssp_dupl_res_vec[ dssp_non_null_indices[ index ] ], arg_bifur_hbond_list[ index ], normal_index_of_dssp_index );
if ( diff_str ) {
return ( num_prob ? *num_prob : string{} ) + *diff_str;
}
}
return num_prob
? make_optional( *num_prob + " No differences spotted until the end of the shortest" )
: none;
}
示例4:
/// \brief Generate a string describing the difference between the specified dssp_dupl_res parsed from a DSSP file
/// and the specified bifur_hbond or return none if there isn't any difference
///
/// \relates dssp_dupl_res
str_opt cath::sec::difference_string(const dssp_dupl_res &arg_dssp_dupl_res, ///< A dssp_dupl_res parsed from a DSSP file
const bifur_hbond &arg_bifur_hbond, ///< The dssp_dupl_res to be compared to the dssp_dupl_res
const size_vec &arg_normal_index_of_dssp_index ///< A mapping from normal index to the DSSP index
) {
const auto &res_idx = arg_dssp_dupl_res.residue_index;
const str_opt nh_1st = difference_string( "nh-1st", mapped_dsspfile_hbond( arg_dssp_dupl_res.hbonds_this_nh_1st_2nd.first, res_idx, arg_normal_index_of_dssp_index ), arg_bifur_hbond.get_bound_pair_for_this_nh().first );
const str_opt nh_2nd = difference_string( "nh-2nd", mapped_dsspfile_hbond( arg_dssp_dupl_res.hbonds_this_nh_1st_2nd.second, res_idx, arg_normal_index_of_dssp_index ), arg_bifur_hbond.get_bound_pair_for_this_nh().second );
const str_opt co_1st = difference_string( "co-1st", mapped_dsspfile_hbond( arg_dssp_dupl_res.hbonds_this_co_1st_2nd.first, res_idx, arg_normal_index_of_dssp_index ), arg_bifur_hbond.get_bound_pair_for_this_co().first );
const str_opt co_2nd = difference_string( "co-2nd", mapped_dsspfile_hbond( arg_dssp_dupl_res.hbonds_this_co_1st_2nd.second, res_idx, arg_normal_index_of_dssp_index ), arg_bifur_hbond.get_bound_pair_for_this_co().second );
const string suffix_string = " at DSSP residue "
+ to_string( arg_dssp_dupl_res.pdb_residue_name )
+ " (index "
+ ::std::to_string( res_idx )
+ ")";
return
nh_1st ? make_optional( *nh_1st + suffix_string ):
nh_2nd ? make_optional( *nh_2nd + suffix_string ):
co_1st ? make_optional( *co_1st + suffix_string ):
co_2nd ? make_optional( *co_2nd + suffix_string ):
none;
}
示例5: make_optional
optional<double> TestWeightingFunc(const Student& student1,
const Student& student2) {
if ((student1 == Student{147195} && student2 == Student{147195}) ||
(student2 == Student{147195} && student1 == Student{147195})) {
return boost::none;
} else if ((student1 == Student{147195} && student2 == Student{312995}) ||
(student2 == Student{147195} && student1 == Student{312995})) {
return make_optional(3.);
} else if ((student1 == Student{147195} && student2 == Student{352468}) ||
(student2 == Student{147195} && student1 == Student{352468})) {
return make_optional(2.);
} else if ((student1 == Student{147195} && student2 == Student{500928}) ||
(student2 == Student{147195} && student1 == Student{500928})) {
return make_optional(1.);
} else if ((student1 == Student{147195} && student2 == Student{567890}) ||
(student2 == Student{147195} && student1 == Student{567890})) {
return boost::none;
} else if ((student1 == Student{312995} && student2 == Student{312995}) ||
(student2 == Student{312995} && student1 == Student{312995})) {
return boost::none;
} else if ((student1 == Student{312995} && student2 == Student{352468}) ||
(student2 == Student{312995} && student1 == Student{352468})) {
return make_optional(3.);
} else if ((student1 == Student{312995} && student2 == Student{500928}) ||
(student2 == Student{312995} && student1 == Student{500928})) {
return make_optional(2.);
} else if ((student1 == Student{312995} && student2 == Student{567890}) ||
(student2 == Student{312995} && student1 == Student{567890})) {
return boost::none;
} else if ((student1 == Student{352468} && student2 == Student{352468}) ||
(student2 == Student{352468} && student1 == Student{352468})) {
return boost::none;
} else if ((student1 == Student{352468} && student2 == Student{500928}) ||
(student2 == Student{352468} && student1 == Student{500928})) {
return make_optional(3.);
} else if ((student1 == Student{352468} && student2 == Student{567890}) ||
(student2 == Student{352468} && student1 == Student{567890})) {
return boost::none;
} else if ((student1 == Student{500928} && student2 == Student{500928}) ||
(student2 == Student{500928} && student1 == Student{500928})) {
return boost::none;
} else if ((student1 == Student{500928} && student2 == Student{567890}) ||
(student2 == Student{500928} && student1 == Student{567890})) {
return boost::none;
} else if ((student1 == Student{567890} && student2 == Student{567890}) ||
(student2 == Student{567890} && student1 == Student{567890})) {
return boost::none;
}
assert(false);
}
示例6: to_string
/// \brief Generate a string describing the specified hit_arch in the specified format
///
/// This is deliberately separated from a normal to_string() function because
/// the interface requirements of this may change (eg to demand that the client
/// passes the crh_score_spec, trim_spec, hits_boundary_output)
///
/// \relates hit_arch
string cath::rslv::to_output_string(const hit_arch &arg_hit_arch, ///< The hit_arch to describe
const full_hit_list &arg_full_hits, ///< The list of labels corresponding to the hit
const trim_spec &arg_trim_spec, ///< The trim_spec specifying any trimming that should be performed on the output segments
const hit_output_format &arg_format, ///< The format in which the hit_arch should be described
const string &arg_prefix, ///< Any prefix that should come before the hit in hit_output_format::JON
const hit_boundary_output &arg_boundary_output ///< Whether to output the trimmed or original boundaries
) {
const bool is_jon = ( arg_format == hit_output_format::JON );
const string prefix = is_jon ? "" : "hit_arch[\n\t";
const string separator = is_jon ? "\n" : "\n\t";
const string suffix = is_jon ? "\n" : "\n]";
const auto arch_full_hits = full_hit_list{ transform_build<full_hit_vec>(
arg_hit_arch,
[&] (const calc_hit &x) { return arg_full_hits[ x.get_label_idx() ]; }
) };
return prefix
+ join(
arch_full_hits
| transformed( [&] (const full_hit &x) {
return to_string(
x,
arg_format,
arg_prefix,
make_optional( arg_boundary_output == hit_boundary_output::TRIMMED, arg_trim_spec )
)
+ (
is_jon
? " " + get_all_resolved_segments_string( x, arch_full_hits, arg_trim_spec )
: ""s
)
+ (
is_jon && x.get_alnd_rgns_opt()
? " " + to_string( *x.get_alnd_rgns_opt() )
: ""s
);
} ),
separator
)
+ suffix;
}