本文整理汇总了C++中boost::optional::size方法的典型用法代码示例。如果您正苦于以下问题:C++ optional::size方法的具体用法?C++ optional::size怎么用?C++ optional::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::optional
的用法示例。
在下文中一共展示了optional::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: swap
void url::
rebuild(const boost::string_ref &scheme,
const boost::optional<boost::string_ref> &host,
const boost::optional<uint16_t> &port,
const boost::optional<boost::string_ref> &path,
const boost::optional<boost::string_ref> &query,
const boost::optional<boost::string_ref> &fragment,
const boost::optional<boost::string_ref> &user_info)
{
std::string str;
str.append(scheme.data(), scheme.size());
if (has_authority()) {
str.append("://");
if (user_info) {
str.append(user_info->data(), user_info->size());
str.append("@");
}
str.append(host->data(), host->size());
if (port) {
str.append(":");
str.append(std::to_string(*port));
}
}
else {
str.append(":");
}
if (path) {
str.append(path->data(), path->size());
}
if (query) {
str.append("?");
str.append(query->data(), query->size());
}
if (fragment) {
str.append("#");
str.append(fragment->data(), fragment->size());
}
url new_url { std::move(str) };
swap(new_url);
}
示例2: get_face_set
face_set_ptr face_manager<T>::get_face_set(const std::string &name, boost::optional<font_set> fset)
{
if (fset && fset->size() > 0)
{
return get_face_set(*fset);
}
else
{
return get_face_set(name);
}
}
示例3: pointsX
vector<CubicBezierControlPoints> RRTPlanner::generateCubicBezierPath(
const vector<Geometry2d::Point>& points,
const MotionConstraints& motionConstraints, Geometry2d::Point vi,
Geometry2d::Point vf, const boost::optional<vector<float>>& times) {
size_t length = points.size();
size_t curvesNum = length - 1;
vector<double> pointsX(length);
vector<double> pointsY(length);
vector<double> ks(length - 1);
vector<double> ks2(length - 1);
for (int i = 0; i < length; i++) {
pointsX[i] = points[i].x;
pointsY[i] = points[i].y;
}
const float startSpeed = vi.mag();
const float endSpeed = vf.mag();
if (times) {
assert(times->size() == points.size());
for (int i = 0; i < curvesNum; i++) {
ks[i] = 1.0 / (times->at(i + 1) - times->at(i));
ks2[i] = ks[i] * ks[i];
if (std::isnan(ks[i])) {
debugThrow(
"Something went wrong. Points are too close to each other "
"probably");
return vector<CubicBezierControlPoints>();
}
}
} else {
for (int i = 0; i < curvesNum; i++) {
ks[i] = 1.0 / (getTime(points, i + 1, motionConstraints, startSpeed,
endSpeed) -
getTime(points, i, motionConstraints, startSpeed,
endSpeed));
ks2[i] = ks[i] * ks[i];
if (std::isnan(ks[i])) {
debugThrow(
"Something went wrong. Points are too close to each other "
"probably");
return vector<CubicBezierControlPoints>();
}
}
}
VectorXd solutionX =
RRTPlanner::cubicBezierCalc(vi.x, vf.x, pointsX, ks, ks2);
VectorXd solutionY =
RRTPlanner::cubicBezierCalc(vi.y, vf.y, pointsY, ks, ks2);
vector<CubicBezierControlPoints> path;
for (int i = 0; i < curvesNum; i++) {
Point p0 = points[i];
Point p1 = Geometry2d::Point(solutionX(i * 2), solutionY(i * 2));
Point p2 =
Geometry2d::Point(solutionX(i * 2 + 1), solutionY(i * 2 + 1));
Point p3 = points[i + 1];
path.emplace_back(p0, p1, p2, p3);
}
return path;
}