Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
accessibility on in-class typedefs
//g++ 4.9.3 #include <iostream> template<typename T> class QScopedPointer { //type alias does not need to be made public in order to use them in //public member functions as shown below. //you can use both syntax //typedef T* QScopedPointer::* RestrictedBool; using RestrictedBool = T* QScopedPointer::*; public: QScopedPointer(T* _d):d(_d){} inline operator RestrictedBool() const { return d==nullptr? nullptr : &QScopedPointer::d; } private: T* d; }; int main() { int a = 1; QScopedPointer<int> q1(&a); if(q1) std::cout<<"q1 has a pointer" << std::endl; else std::cout <<"q1 not has a pointer" << std::endl; return 0; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Double_wrapper vc++
Multi Inheritance
primitive type copy constructor
VS struct name enumerate
Error log b is an undeclared identifier...
No UD
algorithm_1
problem_solution_1
seh exception
iterator by value, by reference
stackse - search stackoverflow differently
Please log in to post a comment.