Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
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
ToString library for C++
hangman
atoi on hex
😊
#21.2
Computing factorial of an integer with recursion and iteration
vector destruction - visual studio
Spirit Lex combining token_id's with semantic actions
infix to postfix v 3.0
C++ MSVN Compiler Type Check