We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug A clear and concise description of what the bug is.
#include <string> #include <iostream> #include <vector> using namespace std; template <class T> constexpr std::string_view type_name() { using namespace std; #ifdef __clang__ string_view p = __PRETTY_FUNCTION__; return string_view(p.data() + 34, p.size() - 34 - 1); #elif defined(__GNUC__) string_view p = __PRETTY_FUNCTION__; # if __cplusplus < 201402 return string_view(p.data() + 36, p.size() - 36 - 1); # else return string_view(p.data() + 49, p.find(';', 49) - 49); # endif #elif defined(_MSC_VER) string_view p = __FUNCSIG__; return string_view(p.data() + 84, p.size() - 84 - 7); #endif } /** * description : to .<br/><br/> * * @val : value **/ class A { public: A() {} ~A() {} vector<int>& vref() { return v_; } vector<int>* vpoint() { return &v_; } void output() { for (auto i : v_) { cout << i << endl; } } private: vector<int> v_; }; int main(int argc, char** argv) { A ca; cout << "ref:" << endl; auto &v = ca.vref(); v.push_back(1); v.push_back(2); v.push_back(3); ca.output(); std::cout << type_name<decltype(v)>() << endl; cout << "value:" << endl; auto vv = ca.vref(); vv.push_back(4); ca.output(); std::cout << type_name<decltype(vv)>() << endl; cout << "point ref:" << endl; auto *vpr = ca.vpoint(); vpr->push_back(5); ca.output(); std::cout << type_name<decltype(vpr)>() << endl; cout << "point value:" << endl; auto vpv = ca.vpoint(); vpv->push_back(6); ca.output(); std::cout << type_name<decltype(vpv)>() << endl; // cout << "point value ref:" << endl; // [a.cc](http://a.cc/):90:11: error: non-const lvalue reference to type 'std::vector<int> *' cannot bind to a temporary of type 'vector<int> *' // auto &vpvr = ca.vpoint(); // vpvr->push_back(7); // ca.output(); // std::cout << type_name<decltype(vpvr)>() << endl; return 0; }
output
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
A clear and concise description of what the bug is.
output
The text was updated successfully, but these errors were encountered: