Beispiel #1
0
int main(){
    const A a;
    a.f();
    B b;
    b.f();
    
    unique_ptr<B> pb(new B);
    cout<<pb.get()<<endl;
    
    shared_ptr<B> pb3(new B);
    cout<<" "<< pb3.get() <<endl;
    pb3.get()->f();
    
    //c++函数对象, <int (int, int) > 是一个函数签名
    function<int (int, int)> fadd = Add;
    
    cout<<fadd(1,2)<<endl;
    
    //把 fadd 函数的第一个参数绑定为1。返回一个 int (int) 类型的参数
    function<int (int) > fadd1 = bind(fadd, _1, 1);
    cout<<fadd1(100)<<endl;
    
    
    auto t1 = make_tuple(100, 200, 300);
    cout<<get<1>(t1)<<endl;
    ////下面这个会在编译器 报错误
    //cout<<get<3>(t1)<<endl;
    
    // 固定大小的容器
    array<int, 10> array1;
    cout<<array1[1]<<endl;
    
    return 0;
}
int main(){
    A a(1);
    a.f();
    a.g();
    const A b;
    b.f();
//    b.g(); // compile error because g() is not const function
}
Beispiel #3
0
int main ()
{
  return a.f (3);
}
Beispiel #4
0
void g()
{
  f(4);
}
	void f() const {
		a.f();
		B::f();
	}
Beispiel #6
0
 void use() {
   ab.f(); // expected-note {{instantiation of}}
   ab.g();
   ab.h();
 }
Beispiel #7
0
 int main()
 {
 const A a = A();
 a.f();
 }
 void g() {
   f(); // no diagnostic
 }
Beispiel #9
0
 void g() {
   A::f();
   f();
 }
Beispiel #10
0
 void testG(G::C<G::X::A, G::Y::B> gc) { f(gc); }
Beispiel #11
0
 void testF(F::S fs) { f(fs, 0); }
Beispiel #12
0
 void testE(E::S es) { f(es); } // expected-error {{undeclared identifier}}
Beispiel #13
0
 void testD(D::S ds) { f(ds); } // expected-error {{undeclared identifier}}
Beispiel #14
0
	void g() {
		a.f();
	}
Beispiel #15
0
 void reset_ok() {
   this->~UseAfterSelfDestruct();
   x_ = a_.f(x_);
 }
Beispiel #16
0
void g()
{
  f(4);            // ERROR - too many arguments
}
 ~B() { a->f(); };
Beispiel #18
0
void g()
{
    int k;
    using A::f;
    k = f(3);
}
Beispiel #19
0
 void f() const {  // Redefinition
   a.f();
   B::f();
 }
Beispiel #20
0
Datei: dr1.C Projekt: 0day-ci/gcc
void use() { 
  f(3);       
  f();        // { dg-error "" "" { xfail *-*-* } }
}