本文整理汇总了C++中boost::optional::value方法的典型用法代码示例。如果您正苦于以下问题:C++ optional::value方法的具体用法?C++ optional::value怎么用?C++ optional::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::optional
的用法示例。
在下文中一共展示了optional::value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
std::list<std::pair<typename WeightMap::value_type,
std::list<typename Graph::edge_descriptor>>>
yen_ksp(const Graph& g, Vertex<Graph> s, Vertex<Graph> t,
WeightMap wm, IndexMap im, boost::optional<unsigned> K, boost::optional<unsigned> length)
{
using kr_type = Result<typename WeightMap::value_type, Graph>;
// The shortest paths - these we return.
std::list<kr_type> A;
// An empty result if the source and destination are the same.
if (s != t)
{
// The tentative paths - these are candidate paths. It's a
// set, because we want to make sure that a given result can
// show up in the set of tentative results only once. The
// problem is that the algorithm can find the same tentative
// path many times.
std::set<kr_type> B;
// In each iteration we produce the k-th shortest path.
for (int k = 1; !K || k <= K.value(); ++k) {
if (!yen_ksp(g, s, t, wm, im, A, B)) {
// We break the loop if no path was found.
break;
}
if (length && A.back().second.size() > length.value()) {
// We break the loop if the maximum path length was exceeded
A.pop_back();
break;
}
}
}
return A;
}
示例2: conn
#include <boost/filesystem.hpp>
#include <gdbplz/connection.hpp>
#include "../Catch/include/catch.hpp"
TEST_CASE("guessing gdb path", "[connection]")
{
boost::optional<boost::filesystem::path> path = gdbplz::guess_gdb_path();
REQUIRE((!path || boost::filesystem::exists(path.value())) == true);
}
TEST_CASE("launching with non-existing gdb", "[connection]")
{
REQUIRE_THROWS_AS([](){
gdbplz::connection conn("/sfsfsdfwdsfwerfwef/xcvxvfsdfsdfwerwefrsgfdfgdfgergtergdfg");
}(), gdbplz::gdb_not_found);
}