
Trip report: Fall ISO C++ standards meeting - arunc
https://herbsutter.com/2017/11/11/trip-report-fall-iso-c-standards-meeting-albuquerque/amp/
======
tomcam
> we already have memcpy, but bit_cast is safer and also can run at compile
> time.

Can someone smarter than I am explain the significance about bit_cast running
at compile time?

~~~
mediocrebs
So you can have a constexpr (compile-time) code fragment that, say, casts a
float to an unsigned int and extracts the mantissa.

Mostly though, this is fairly unimportant and tedious spec-manship, filling in
some obvious gaps.

We had a version of this in chromium a few years ago. This is a proposal just
picking that up from what I can tell.

~~~
theresistor
Bitcast, including the specific nomenclature, comes from LLVM, which had the
concept more than 10 years ago.

~~~
gpderetta
The concept of bitcasting is as old as programming. In the context of C++, I'm
also pretty sure that the bitcast template, in one form of another, is also
much older than LLVM itself.

------
merraksh
Is there a typo in operator== ?

    
    
      friend bool operator==(const CIString& a, const CIString& b) 
      { return ci_compare(a.s.c_str(), b.s.c_str()) != 0; }
      friend bool operator< (const CIString& a, const CIString& b)
      { return ci_compare(a.s.c_str(), b.s.c_str()) <  0; }
    

This way a<b implies a==b.

------
inetknght
```

for (auto& x : f().things()) { // dangling reference!

mutate(&x);

}

```

Oh shit I think I have to go through a dozen projects in production and fix
some code now. Thanks Herb.

~~~
nikbackm
Are you sure?

If f() returns a value then you have a problem and should fix it, but if f()
instead returns a reference (that is not dangling in itself), then it should
be fine.

~~~
inetknght
_click_

Now it all makes sense. This is what I get for trying to read technical stuff
while drunk at midnight.

------
zcbenz
Wow this website loads incredibly fast.

~~~
vim_wannabe
Sarcasm? There's an 8 second animation until anything shows up. From the
page's stylesheet:

    
    
      body {
        animation: -amp-start 8s steps(1,end) 0s 1 normal both;
      }
    
      @keyframes -amp-start {
        0% {
          visibility: hidden;
        }
        100% {
          visibility: visible;
        }
      }

~~~
MrUnderhill
I think the idea is that it's supposed to hide the content until the page has
loaded entirely, then fade it in, because it "looks faster". But if uMatrix
(or something similar) blocks scripts from ampproject.org, you just get a nice
8s delay. You can get around it by removing /amp/ from the end of the URL (
[https://herbsutter.com/2017/11/11/trip-report-fall-iso-c-
sta...](https://herbsutter.com/2017/11/11/trip-report-fall-iso-c-standards-
meeting-albuquerque/) )

------
idea1434
I would like to see a spaceship operator for floating point comparison, where
a<=>b means a is less than, equal to, or greater than b. It would be useful
for checking that a and b aren't NaN. If either were NaN, then the comparison
would return false.

~~~
Joky
Basically adding an operator to replace the existing `std::is_nan()`? Not sure
if this deserves to be first class in the language...

~~~
idea1434
No, it would be the same as evaluating (a<b)&&(a==b)&&(a>b), not std::is_nan.

~~~
slavik81
A special syntax seems unnecessary. Just drop something like this in your
project:

    
    
      template<typename A, typename B>
      bool is_unordered(const A& a, const B& b) {
        return !(a<b||a==b||a>b);
      }
    

edit: changed implementation to match name.

~~~
idea1434
It just makes more sense. Similar to how a<=b is equivalent to (a<b)&&(a==b).

Coming up with an entirely fresh meaning for <=> involving spaceships and a
conglomerated comparative threesome just seems illogical to me, given the
original meanings of the component symbols of <=>.

~~~
slavik81
This operator already exists in Ruby, Perl and a couple other languages.

It's also incredibly useful, allowing six functions to be replaced by one. Or,
rather, with zero, because in 99.9% of cases you will just be able to declare
the signature with '= default;' and let the compiler generate the
implementation. Then you have all relational operators available for that
type. It makes defining new types much, much easier.

Plus, it provides a place to statically define what sort of ordering the type
has, so further compile-time optimizations can be done.

In contrast, <=> as is_ordered is nearly useless. It would basically only be
used for floats, where !(isnan(a)||isnan(b)) is both equivalent and IMO more
clear.

