本文整理汇总了C++中boost::make_iterator_range方法的典型用法代码示例。如果您正苦于以下问题:C++ boost::make_iterator_range方法的具体用法?C++ boost::make_iterator_range怎么用?C++ boost::make_iterator_range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost
的用法示例。
在下文中一共展示了boost::make_iterator_range方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getAllFilesWithExt
FileList getAllFilesWithExt(SearchPath dirPath, const std::string &ext) {
FileList filesPaths;
for (const auto &path : dirPath) {
using boost::filesystem::directory_iterator;
using boost::make_iterator_range;
boost::filesystem::path directoryPath(path);
// Make sure that directory exists
if (!boost::filesystem::exists(directoryPath)) {
continue;
}
// Get a list of files inside the dir that match the extension
for (const auto &pathName : make_iterator_range(
directory_iterator(directoryPath), directory_iterator())) {
if (!boost::filesystem::is_regular_file(pathName) ||
pathName.path().extension() != ext)
continue;
filesPaths.push_back(pathName.path().generic_string());
}
}
return filesPaths;
}
示例2: main
int main() {
using Value = std::pair<box, int>;
using Tree = bgi::rtree<Value, bgi::rstar<32> >;
Tree idx;
std::vector<point> const points { point {1,10}, point {2,5}, point {5,8}, point {1,2}, point {8,10}, };
for (size_t i = 0; i < points.size(); ++i)
idx.insert(Value { boxof(points[i]), i });
for (auto& entry : make_iterator_range(qbegin(idx, bgi::nearest(point{0,0}, 100)), {}))
std::cout << bg::dsv(points[entry.second]) << " ";
}
示例3: find_in_path
inline boost::optional<std::string>
find_in_path(const std::string &executable) {
using std::string;
using boost::is_equal;
using boost::filesystem::path;
using boost::make_iterator_range;
const string PATH = getenv("PATH");
for (const auto &token : make_iterator_range(
make_split_iterator(PATH, first_finder(":", is_equal())), {})) {
const auto full_path = path(token.begin(), token.end()) / executable;
if (exists(full_path)) {
return full_path.string();
}
}
return {};
}
示例4: findPlugin
std::string findPlugin(const std::string &pluginName) {
auto searchPaths = getPluginSearchPath();
for (const auto &searchPath : searchPaths) {
if (!boost::filesystem::exists(searchPath))
continue;
using boost::filesystem::directory_iterator;
using boost::make_iterator_range;
for (const auto &pluginPathName : make_iterator_range(
directory_iterator(searchPath), directory_iterator())) {
/// Must be a regular file
/// @todo does this mean symlinks get excluded?
if (!boost::filesystem::is_regular_file(pluginPathName))
continue;
const auto pluginCandidate =
boost::filesystem::path(pluginPathName);
/// Needs right extension
if (pluginCandidate.extension().generic_string() !=
OSVR_PLUGIN_EXTENSION) {
continue;
}
const auto pluginBaseName =
pluginCandidate.filename().stem().generic_string();
/// If the name is right or has the manual load suffix, this is
/// a good one.
if ((pluginBaseName == pluginName) ||
(pluginBaseName ==
pluginName + OSVR_PLUGIN_IGNORE_SUFFIX)) {
return pluginPathName.path().generic_string();
}
}
}
return std::string();
}