News for hackers. Stuff that matters.
Re:Deprecating Raw Pointers in C++20 by enitihas on Sunday April 01, 2018 @06:20AM (#16727603)
Can someone with more knowledge about c++ standard comment whether this is for real or it is an April Fools joke. Wouldn't this be an enormous change and probably break the language?
Re:Deprecating Raw Pointers in C++20 by mbel on Sunday April 01, 2018 @06:24AM (#16727618)
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.
Re:Deprecating Raw Pointers in C++20 by evincarofautumn on Sunday April 01, 2018 @09:47AM (#16728225)
Honestly 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.
Re:Deprecating Raw Pointers in C++20 by ChrisSD on Sunday April 01, 2018 @06:22AM (#16727613)
It would break the C interface unless the spec had some kind of wrapper for such cases.
Re:Deprecating Raw Pointers in C++20 by mehrdadn on Sunday April 01, 2018 @06:37AM (#16727642)
If it were for real how would you implement smart pointers?
Re:Deprecating Raw Pointers in C++20 by mbel on Sunday April 01, 2018 @06:40AM (#16727652)
In C obviously or you know, in inline assembly since it seems that it isn't going anywhere. But joking aside they could be implemented by the compilers similar to how std::function is implemented today.
Re:Deprecating Raw Pointers in C++20 by fooker on Sunday April 01, 2018 @06:42AM (#16727654)
There is no magic in std::function Implementation. std::initializer_list, on the other hand needs some magic from the compiler.
Re:Deprecating Raw Pointers in C++20 by mehrdadn on Sunday April 01, 2018 @06:45AM (#16727659)
Inline assembly isn't standard C or C++ though?
Re:Deprecating Raw Pointers in C++20 by foldr on Sunday April 01, 2018 @07:13AM (#16727722)
There have always been library features in the C and C++ standards that can't be implemented using standard C or C++. setjmp and longjmp would be the obvious examples.
Re:Deprecating Raw Pointers in C++20 by pjmlp on Sunday April 01, 2018 @06:57AM (#16727682)
It is pseudo standard in C++.

Meaning ANSI C does not refer at all to inline Assembly, from its point of view it does not exist.

ANSI C++ on other hand, specifies the asm keyword and that it should enable a compiler specific way to write inline Assembly.

But yeah, neither of them actually specifies how it should look.

Re:Deprecating Raw Pointers in C++20 by mbel on Sunday April 01, 2018 @06:57AM (#16727680)
But still can be (and is) used to implement some features from the standard library.
Re:Deprecating Raw Pointers in C++20 by FrankHB on Monday April 02, 2018 @01:52AM (#16732609)
It isn't.

Quoted from the C++ standard: "the asm declaration is conditionally-supported; its meaning is implementation-defined". ISO C does not differ much in conformance (the asm keyword is common extension listed in annex J). There exists implementation without inline assembly support, e.g. MSVC x64. There are alternative keywords used in practice (e.g. `__asm` or `__asm__ __volatile__`). Actually the contents are not supposed to be assembly language in all cases when it is supported, as I know there exists implementation with JavaScript as the "assembly" (Cheerp). Even the implementation supports "genuine" assembly, it varies in syntax, e.g. for x86, Intel (MSVC), AT&T (Clang), or both (GCC) ?

So no, you can't expect it too much, if you have to.