void g() { const B b; int *pi; pi = b.f(0); }
void h() { using B::f; using C::f; f('h'); f(1); // { dg-error "ambiguous" } // { dg-message "candidate" "candidate note" { target *-*-* } 22 } void f(int); // { dg-error "previous using declaration" } }
/// Access a non-zero element inline DataType& at(int k) { try { if (k<0) k+=nnz(); return data().at(k); } catch(std::out_of_range& /* unnamed */) { std::stringstream ss; ss << "Out of range error in Matrix<>::at: " << k << " not in range [0, " << nnz() << ")"; throw CasadiException(ss.str()); } }
int main() { B b1; const B b2 = B(); b1.f (); b2.g (); b2.h (); b1.i (); }
int main() { std::vector<A> veca(1); std::vector<B> vecb(1); std::cout << veca[0].geta()<<" "<<vecb[0].geta() << " " << vecb[0].getb() << std::endl; A a; B b; std::cout << a.geta()<<" "<<b.geta() << " "<<b.getb() << std::endl; std::cout << g_a.geta()<<" "<<g_b.geta() <<" "<<g_b.getb()<<std::endl; return 0; }
int main() { using B::g; g('a'); // calls B::g(char) struct g g1; // g1 has class type B::g B::h( &g1 ); if( g1.g != -34 ) _fail; _PASS; }
void A::doIt() { cout << "A::doIt" << endl; if (aB) { aB->deleteTheA(); } cout << "exit: A::doIt" << endl; }
int main() { abc = 0xcafe0210; #if 1 char x = 0xff; short y = 0xcafe; A b; b.x = 0xcafe0110; b.y = 0xcafe0111; b.foo(); D d; d.foo(); d.x = 0xcafe0112; #endif return 0; }
void A::test() { if (b->fun_use_thread() == 0) { while(global->per < 100) { key = getch(); if ( (dem < 100) && (key != '\n')) { s[dem] = key; s[dem + 1] = '\0'; dem ++; } } }else { printf("Can not creat thread\n"); } }
int main() { const B b1; assert(b1.func() == false); }
typename base::Field at(typename base::Coord x) { return left.at(x) + right.at(x); }
~A() { cout << "In destructor of A, the val in b is:" << b->getV() << endl; delete b; }
// // the following two functions access // private member functions of class B // and they should not be able to do so // virtual void setBValue(int i) { if (bobject) bobject->Number(i); }// ERROR - .*
int main() { assert(b.get_i()==0); }
explicit set_bits_iter(B const& b) : b(&b),i(b.find_first()) {}
void C::fn2 () { if (!foo) return; foo->fn (0, 0, 0); }
int call_element() { return element->vfunc(); }
/// \cond INTERNAL /// Get a pointer to the data DataType* ptr() { return isempty() ? static_cast<DataType*>(0) : &front();}
virtual int getBValue() { if (bobject) { return bobject->Number(); } return 0; }// ERROR - .*
int foo () { return b_int.value(); }
namespace InhCtor { struct A { A(int); protected: int T(); }; typedef A T; struct B : A { // This is a using-declaration for 'int A::T()' in C++98, but is an // inheriting constructor declaration in C++11. using InhCtor::T::T; }; #if __cplusplus < 201103L B b(123); // expected-error {{no matching constructor}} // expected-note@-7 2{{candidate constructor}} int n = b.T(); // ok, accessible #else B b(123); // ok, inheriting constructor int n = b.T(); // expected-error {{'T' is a protected member of 'InhCtor::A'}} // expected-note@-15 {{declared protected here}} // FIXME: EDG and GCC reject this too, but it's not clear why it would be // ill-formed. template<typename T> struct S : T { struct U : S { // expected-note 6{{candidate}} using S::S; }; using T::T; }; S<A>::U ua(0); // expected-error {{no match}} S<B>::U ub(0); // expected-error {{no match}} template<typename T> struct X : T { using T::Z::U::U; }; template<typename T> struct X2 : T { using T::Z::template V<int>::V; }; struct Y { struct Z { typedef Y U; template<typename T> using V = Y; }; Y(int); }; X<Y> xy(0); namespace Repeat { struct A { struct T { T(int); }; }; struct Z : A { using A::A::A; }; template<typename T> struct ZT : T::T { using T::T::T; }; } namespace NS { struct NS {}; } struct DerivedFromNS : NS::NS { // No special case unless the NNS names a class. using InhCtor::NS::NS; // expected-error {{using declaration in class refers into 'InhCtor::NS::', which is not a class}} }; // FIXME: Consider reusing the same diagnostic between dependent and non-dependent contexts typedef int I; struct UsingInt { using I::I; // expected-error {{'I' (aka 'int') is not a class, namespace, or enumeration}} }; template<typename T> struct UsingIntTemplate { using T::T; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}} }; UsingIntTemplate<int> uit; // expected-note {{here}} #endif }
inline void advance() { i=b->find_next(i); }
int main() { CHECK(fcc::invoke(f) == 13); CHECK(noexcept(fcc::invoke(f) == 13)); CHECK(fcc::invoke(g, 2) == 5); CHECK(fcc::invoke(h, 42) == 42); CHECK(noexcept(fcc::invoke(h, 42) == 42)); { int i = 13; CHECK(&fcc::invoke(h, i) == &i); CHECK(noexcept(&fcc::invoke(h, i) == &i)); } CHECK(fcc::invoke(&A::f, A{}) == 42); CHECK(noexcept(fcc::invoke(&A::f, A{}) == 42)); CHECK(fcc::invoke(&A::g, A{}, 2) == 4); { A a; const auto& ca = a; CHECK(fcc::invoke(&A::f, a) == 42); CHECK(noexcept(fcc::invoke(&A::f, a) == 42)); CHECK(fcc::invoke(&A::f, ca) == 42); CHECK(noexcept(fcc::invoke(&A::f, ca) == 42)); CHECK(fcc::invoke(&A::g, a, 2) == 4); } { A a; const auto& ca = a; CHECK(fcc::invoke(&A::f, &a) == 42); CHECK(noexcept(fcc::invoke(&A::f, &a) == 42)); CHECK(fcc::invoke(&A::f, &ca) == 42); CHECK(noexcept(fcc::invoke(&A::f, &ca) == 42)); CHECK(fcc::invoke(&A::g, &a, 2) == 4); } { auto up = std::make_unique<A>(); CHECK(fcc::invoke(&A::f, up) == 42); CHECK(fcc::invoke(&A::g, up, 2) == 4); } { auto sp = std::make_shared<A>(); CHECK(fcc::invoke(&A::f, sp) == 42); CHECK(noexcept(fcc::invoke(&A::f, sp) == 42)); CHECK(fcc::invoke(&A::g, sp, 2) == 4); } CHECK(fcc::invoke(&A::i, A{}) == 13); CHECK(noexcept(fcc::invoke(&A::i, A{}) == 13)); { int&& tmp = fcc::invoke(&A::i, A{}); (void)tmp; } { A a; const auto& ca = a; CHECK(fcc::invoke(&A::i, a) == 13); CHECK(noexcept(fcc::invoke(&A::i, a) == 13)); CHECK(fcc::invoke(&A::i, ca) == 13); CHECK(noexcept(fcc::invoke(&A::i, ca) == 13)); CHECK(fcc::invoke(&A::i, &a) == 13); CHECK(noexcept(fcc::invoke(&A::i, &a) == 13)); CHECK(fcc::invoke(&A::i, &ca) == 13); CHECK(noexcept(fcc::invoke(&A::i, &ca) == 13)); fcc::invoke(&A::i, a) = 0; CHECK(a.i == 0); fcc::invoke(&A::i, &a) = 1; CHECK(a.i == 1); static_assert(std::is_same<decltype(fcc::invoke(&A::i, ca)), const int&>{}); static_assert(std::is_same<decltype(fcc::invoke(&A::i, &ca)), const int&>{}); } { auto up = std::make_unique<A>(); CHECK(fcc::invoke(&A::i, up) == 13); fcc::invoke(&A::i, up) = 0; CHECK(up->i == 0); } { auto sp = std::make_shared<A>(); CHECK(fcc::invoke(&A::i, sp) == 13); fcc::invoke(&A::i, sp) = 0; CHECK(sp->i == 0); } { struct B { int i = 42; constexpr int f() const { return i; } }; constexpr B b; static_assert(b.i == 42); static_assert(b.f() == 42); static_assert(fcc::invoke(&B::i, b) == 42); static_assert(fcc::invoke(&B::i, &b) == 42); static_assert(fcc::invoke(&B::i, B{}) == 42); static_assert(fcc::invoke(&B::f, b) == 42); static_assert(fcc::invoke(&B::f, &b) == 42); static_assert(fcc::invoke(&B::f, B{}) == 42); } return ::test_result(); }
void D::f(int) { f('c'); } // calls B::f(char)
struct foo; struct bar { }; typedef bar baz; extern int var_decl; void func_decl(void); extern int var_fwd; void func_fwd(void); } } namespace A { using namespace B; } using namespace A; namespace E = A; int B::i = f1(); int func(bool b) { if (b) { using namespace A::B; return i; } using namespace A; using B::foo; using B::bar; using B::f1; using B::i; using B::baz; namespace X = A; namespace Y = X; using B::var_decl; using B::func_decl;
void g() { b.g(); // expected-error{{no member named 'g' in 'A::B'}} }
~I () { bc->h (); }
void go() { b.print_x(); }
/// Get a const pointer to the data const DataType* ptr() const { return isempty() ? static_cast<const DataType*>(0) : &front();}
void print_b() const { b.print(); }