本文整理汇总了C++中Foo函数的典型用法代码示例。如果您正苦于以下问题:C++ Foo函数的具体用法?C++ Foo怎么用?C++ Foo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Foo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(Result, inspect)
{
struct Foo
{
int val;
Foo(int v) : val(v) {}
Foo(Foo&&) = default;
Foo(const Foo&) = delete;
Foo& operator = (Foo&&) = default;
Foo& operator = (const Foo&) = delete;
bool operator == (const Foo& other) const
{
return this->val == other.val;
}
};
Result<Foo> foo = Ok(Foo(1));
EXPECT_TRUE(foo.is_ok());
EXPECT_FALSE(foo.is_err());
EXPECT_EQ(foo.get_success(), Some(Foo(1)));
EXPECT_EQ(foo.get_failure(), ""_s);
foo = Err("oops"_s);
EXPECT_FALSE(foo.is_ok());
EXPECT_TRUE(foo.is_err());
EXPECT_EQ(foo.get_success(), None<Foo>());
EXPECT_EQ(foo.get_failure(), "oops"_s);
}
示例2: TEST
TEST( Hit_Check_Test, CircleHit ){
wing::DefaltLoader Loader;
auto img = Loader.load();
{
TestSprite Hoge(60,60,img,wing::Position(-10,20));
TestSprite Foo(80,80,img,wing::Position(80,-10));
ASSERT_EQ(wing::sprite::checkRectHit(Hoge, Hoge) , false);
ASSERT_EQ(wing::sprite::checkCircleHit(Hoge, Foo) , false);
}
{
TestSprite Hoge(60,60,img,wing::Position(-0,0));
TestSprite Foo(80,80,img,wing::Position(20,0));
ASSERT_EQ(wing::sprite::checkCircleHit(Hoge, Foo) , true);
}
{
TestSprite Hoge(60,60,img,wing::Position(0,0));
TestSprite Foo(80,80,img,wing::Position(70,0));
ASSERT_EQ(wing::sprite::checkCircleHit(Hoge, Foo) , false);
}
}
示例3: AssertFoo
testing::AssertionResult AssertFoo(const char* m_expr, const char* n_expr, const char* k_expr, int m, int n, int k) {
if (Foo(m, n) == k)
return testing::AssertionSuccess();
testing::Message msg;
msg << m_expr << " 和 " << n_expr << " 的最大公约数应该是:" << Foo(m, n) << " 而不是:" << k_expr;
return testing::AssertionFailure(msg);
}
示例4: decode
int64_t decode(void *buffer, size_t size, int64_t sum)
{
unsigned int i;
C(table_t) foobarcontainer;
FooBar(vec_t) list;
FooBar(table_t) foobar;
Bar(struct_t) bar;
Foo(struct_t) foo;
foobarcontainer = C(as_root(buffer));
sum += C(initialized(foobarcontainer));
sum += StringLen(C(location(foobarcontainer)));
sum += C(fruit(foobarcontainer));
list = C(list(foobarcontainer));
for (i = 0; i < FooBar(vec_len(list)); ++i) {
foobar = FooBar(vec_at(list, i));
sum += StringLen(FooBar(name(foobar)));
sum += FooBar(postfix(foobar));
sum += (int64_t)FooBar(rating(foobar));
bar = FooBar(sibling(foobar));
sum += (int64_t)Bar(ratio(bar));
sum += Bar(size(bar));
sum += Bar(time(bar));
foo = Bar(parent(bar));
sum += Foo(count(foo));
sum += Foo(id(foo));
sum += Foo(length(foo));
sum += Foo(prefix(foo));
}
return sum + 2 * sum;
}
示例5: Test2
void Test2() {
// CHECK-DTOR-LABEL: Test2
// CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR1:[0-9]+]])
// CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
// CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
// CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR2:[0-9]+]])
// CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
// CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
// CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR2]])
// CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR2]])
// CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR1]])
// CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR1]])
// CHECK-DTOR: }
// CHECK-NO-DTOR-LABEL: Test2
// CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR1:[0-9]+]])
// CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
// CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
// CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR2:[0-9]+]])
// CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
// CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
// CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR2]])
// CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR1]])
// CHECK-NO-DTOR: }
const A &a = A{};
Foo(a);
const A &b = A{};
Foo(b);
}
示例6: Test1
void Test1() {
// CHECK-DTOR-LABEL: Test1
// CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR:[0-9]+]])
// CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
// CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
// CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
// CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR]])
// CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR:[0-9]+]])
// CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
// CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
// CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
// CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR]])
// CHECK-DTOR: }
// CHECK-NO-DTOR-LABEL: Test1
// CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR:[0-9]+]])
// CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
// CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
// CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR]])
// CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR:[0-9]+]])
// CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
// CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
// CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR]])
// CHECK-NO-DTOR: }
{
const A &a = A{};
Foo(a);
}
{
const A &a = A{};
Foo(a);
}
}
示例7: TEST
TEST(FooTest, HandleNoneZeroInput)
{
EXPECT_EQ(2, Foo(4, 10));
EXPECT_EQ(6, Foo(30, 18));
}
示例8: UserTypeInContainer
void UserTypeInContainer(YAML::Emitter& out, std::string& desiredOutput)
{
std::vector<Foo> fv;
fv.push_back(Foo(5, "hello"));
fv.push_back(Foo(3, "goodbye"));
out << fv;
desiredOutput = "- x: 5\n bar: hello\n- x: 3\n bar: goodbye";
}
示例9: main
int main()
{
Foo( 12, 345, 678, 90 );
Foo( 11, 22, 33, 44 );
Foo( 99, 88, 77, 66 );
return 0;
}
示例10: foo
void foo()
{
std::cout << "========== Foo ==============\n";
Foo foo = Foo() + Foo();
std::cout << "=============================\n";
}
示例11: UserType
void UserType(YAML::Emitter& out, std::string& desiredOutput)
{
out << YAML::BeginSeq;
out << Foo(5, "hello");
out << Foo(3, "goodbye");
out << YAML::EndSeq;
desiredOutput = "- x: 5\n bar: hello\n- x: 3\n bar: goodbye";
}
示例12: Bar
void Bar(T... t)
{
Foo(t...); // invokes Foo once with all arguments in the pack
std::cout << "------------------\n";
using swallow = int[];
void(swallow{0, (void(Foo(t)), 0)...}); // invokes Foo once for each argument in the pack
}
示例13: main
int main()
{
Foo({}, {}); // Foo(int = 0, int = 0)
Foo({1}, {2}); // Foo(int = 1, int = 2)
Foo({1, 2}); // Foo(int = 1, int = 2)
bar({}, {}); // bar(int = 0, int = 0)
bar({1}, {2}); // bar(int = 1, int = 2)
bar({1, 2}); // error: no matching function for call to 'bar' <<< Why? <<<
}
示例14: main
int main(int argc, char** argv)
{
unsigned long int num;
puts("Enter the number:");
scanf("%lu",&num);
printf("%lu",Foo(num)); // Виклик функції
PrintBinary(num); // Друк (2 код) аргумента
PrintBinary(Foo(num)); // Друк (2 код) результату
return 0;
}
示例15: main
int main(int argc, char** argv)
{
unsigned long int num;
puts("Enter the number:");
scanf("%lu",&num);
printf("%lu",Foo(num)); // Виклик ф-ції Foo
PrintBinary(num);
PrintBinary(Foo(num));
return 0;
}