本文整理汇总了C++中range::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ range::empty方法的具体用法?C++ range::empty怎么用?C++ range::empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类range
的用法示例。
在下文中一共展示了range::empty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
template <typename Iter, typename Other> inline bool
operator == (range<Iter> const &value, range<Other> const &other) {
if (value.size() == other.size()) {
return value.empty() ? true : std::equal(value.begin(), value.end(), other.begin());
}
return false;
}
示例2: strncmp
inline bool
operator == (range<char const*> const &value, range<char const*> const &other) {
if (value.size() == other.size()) {
return value.empty() ? true : strncmp(value.begin(), other.begin(), value.size()) == 0;
}
return false;
}
示例3: compare
void compare (Distances distances, Reference const & reference_)
{
auto reference = range::view (reference_);
while (!empty (reference)) {
BOOST_CHECK (!empty (distances));
if (empty (distances))
return;
auto d = chop_in_place (distances);
auto r = chop_in_place (reference);
BOOST_CHECK_EQUAL (first (d), first (r));
BOOST_CHECK_EQUAL (second (d), second (r));
}
BOOST_CHECK (empty (distances));
}
示例4: check_repeat_a
template <class Parser> void check_repeat_a (Parser const & parser) {
using range::empty; using range::first; using range::drop;
{
std::string r ("aa");
auto result = parse (parser, r);
BOOST_CHECK (success (result));
auto o = output (result);
BOOST_CHECK (!empty (o));
BOOST_CHECK (!empty (drop (o)));
BOOST_CHECK (empty (drop (drop (o))));
BOOST_CHECK_EQUAL (first (o), 'a');
BOOST_CHECK_EQUAL (first (drop (o)), 'a');
BOOST_CHECK (empty (rest (result)));
}
{
std::string r ("ab");
auto result = parse (parser, r);
BOOST_CHECK (success (result));
auto o = output (result);
BOOST_CHECK (!empty (o));
BOOST_CHECK (empty (drop (o)));
BOOST_CHECK_EQUAL (first (o), 'a');
BOOST_CHECK_EQUAL (first (rest (result)), 'b');
}
{
std::string r ("b");
auto result = parse (parser, r);
BOOST_CHECK (success (result));
auto o = output (result);
BOOST_CHECK (empty (o));
BOOST_CHECK_EQUAL (first (rest (result)), 'b');
}
}
示例5: write_code_file
void write_code_file(range const& file, range const& file_type) {
int output_pipe[2];
if (-1 == pipe(output_pipe)) {
std::cerr << "could not create pipe for source-highlight\n";
return;
}
int cpid = fork();
if (-1 == cpid) {
std::cerr << "could not create fork for source-highlight\n";
return;
}
if (! cpid) {
// source-highlight process
close(output_pipe[0]);
dup2(output_pipe[1], STDOUT_FILENO);
std::string fileStr = file; // to append null
if (file_type.empty())
execlp(
"source-highlight", "source-highlight",
"-i", fileStr.c_str(), 0);
else {
std::string typeStr = file_type;
execlp(
"source-highlight", "source-highlight",
"-s", typeStr.c_str(), "-i", fileStr.c_str(), 0);
}
std::cerr << "could not execute source-highlight\n";
close(output_pipe[1]);
return;
}
else {
close(output_pipe[1]);
print_source_highlight(output_pipe[0]);
close(output_pipe[0]);
}
}