3 ms·
It seems to be a joke, they would have serious problem with backward compatibility with "this" pointer. Also it would limit the use cases for the language, unle
by mbel 9y ago
It seems to be a joke, they would have serious problem with backward compatibility with "this" pointer. Also it would limit the use cases for the language, unless they would introduce something like std::raw_ptr, which to be honest would be quite funny.
- evincarofautumn 9y agoHonestly this wouldn’t be a bad idea for consistency, teaching, and template programming purposes: namespace std { template<typename T> using raw_ptr = T*; } // mutable pointer to const value int const *a_old; std::raw_ptr<int const> a_new; std::raw_ptr<const int> a_new_var; // const pointer to mutable value int *const b_old; std::raw_ptr<int> const b_new; const std::raw_ptr<int> b_new_var; // const pointer to const value int const *const c_old; std::raw_ptr<int const> const c_new; const std::raw_ptr<const int> c_new_var; I’ve actually used this before to parameterise a struct/class with an ownership policy, for example: template<template<typename T, typename...> class P> struct Wrapper { P<int> value; }; Now Wrapper<std::raw_ptr> is a non-owning Wrapper, while Wrapper<std::unique_ptr> is an owning one.