
Looking at C++14 - jlemoine
http://meetingcpp.com/index.php/br/items/looking-at-c14.html
======
diydsp
>C++14 brings core language support for binary literals, which means you now
can integrate binary literals as such in your code:

>char c = 0b01011010

I can't believe this took TWENTY YEARS (or at least that's how long I
personally have been waiting). Hurray! (I'm going to hobble my walker over to
the desktop and start codin' binary.)

~~~
pkrumins
Here's one of my all-time favorite way to write binary literals in C by
abusing define:

    
    
        #define HEXIFY(X) 0x##X##LU
    
        #define B8IFY(Y) (((Y&0x0000000FLU)?1:0)  + \
                         ((Y&0x000000F0LU)?2:0)  + \
                         ((Y&0x00000F00LU)?4:0)  + \
                         ((Y&0x0000F000LU)?8:0)  + \
                         ((Y&0x000F0000LU)?16:0) + \
                         ((Y&0x00F00000LU)?32:0) + \
                         ((Y&0x0F000000LU)?64:0) + \
                         ((Y&0xF0000000LU)?128:0))
    
        #define B8(Z) ((unsigned char)B8IFY(HEXIFY(Z)))
    

And now you can write:

    
    
        B(01011010)
    

Etc.

If you like this, see my blog post about bithacks.h:

[http://www.catonmat.net/blog/bit-hacks-header-
file/](http://www.catonmat.net/blog/bit-hacks-header-file/)

~~~
dbaupp
Using octal (0o) gives you larger representable numbers, fwiw.

------
platform
C++ is still missing optional Reflection/Introspection. With that feature it
could easily replace majority of todays typed languages (with exception of
language such has Haskell or Rust). Reason is that reflextion allows to close
a 'external data types' dissonance that currently is present in C++. In other
words it is not possible to develop 'framework software' that can introspect
plugin/consumer code to derive how they view the externally defined data
sources (eg Databases, UI kits, JSON streams/etc).

~~~
jjoonathan
The first time I wondered how the hell C++ didn't support introspection, I was
1/3 as old as I am now. I have literally been wondering for most of my life.

But hey, at least they have a Turing-complete template language to go with
their macros! Priorities, right?

~~~
vinkelhake
Yes, priorities. The evolution of C++ is driven by its users in the industry.
That C++ not yet has support for reflection or introspection is an indication
that there hasn't yet been a great need for it.

Any C++ user (you know, the people who actually _use_ the language) will tell
you that templates is a central part of the language and something that is far
more important than introspection.

Anyway, like I said in the other comment, there's a study group for reflection
now. We'll see what comes out of it.

~~~
jjoonathan
> Any C++ user (you know, the people who actually use the language)

Funny, because I _am_ a heavy C++ user (why did you assume differently?). C++
probably accounts for between 1/3 and 1/2 of my lifetime lines-of-code.
Trouble is, I've had to use it for more than algorithms work, which is the
only place I've ever seen templates shine. I've used a half dozen C and C++
GUI frameworks that painstakingly work around the introspection issue, and
while these frameworks often make do quite nicely without templates, they
_always_ have a bolted-on monstrosity of an introspection system. Qt is
probably the most direct example: they built their own preprocessor/parser
around C++ to take care of their need for introspection.

I'm glad there is a study group, but the absence of introspection has been
hurting the C++ community for a long time. It's the flaw that has launched
1,000 high-level languages and 100,000 dirty hacks.

------
sheetjs
What is the current state of C++11 support in major compilers (e.g. G++,
clang, MSVC)

~~~
agwa
It's excellent in GCC and clang. GCC 4.8.1 was feature complete.

GCC C++11 status:
[http://gcc.gnu.org/projects/cxx0x.html](http://gcc.gnu.org/projects/cxx0x.html)

Clang:
[http://clang.llvm.org/cxx_status.html](http://clang.llvm.org/cxx_status.html)

MSVC is not as good. I don't have any links handy, but anecdotally it still
fails to compile some of my code that compiles fine in GCC.

~~~
jzwinck
GCC 4.8 (and even earlier) has <regex> but it doesn't actually work. I guess
it will work in 4.9, but haven't gotten to try it. This glaring omission
somehow didn't make the list you linked, which is otherwise exceedingly
comprehensive.

~~~
agwa
Good point, I guess that table only shows language features.

Here's the library features table:
[http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#s...](http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.200x)

Not feature complete if you take that into account, I'm afraid.

------
mindstab
I was really excited about learning/using some of the new stuff coming in
c++11 and so on until a new job introduced me to Go lang. Now it seems like
all of that stuff and more, elegantly built in instead of bolted on. To be
fair I think it has a big bent towards server apps and not all general purpose
stuff so it only to me seems better for a subset of all c++ work. on the other
hand, Mozilla's Rust also looks interesting. Does anyone else feel like c++ is
finally starting to be replaced in different segments by more target newer
more elegant languages?

~~~
agwa
I don't think Go is attracting many programmers away from C++ (in fact Rob
Pike has expressed surprise at this) because it lacks some of the important
_good_ qualities of C++: strong typing (which Go lacks because of its lack of
templates/generics) and RAII-style resource management. Instead Go is
attracting programmers away from interpreted languages like Python since it
has many of the nice qualities of interpreted languages while being very fast.

Rust may be a different story (still too soon to tell) because it shares many
of the fundamental philosophies of modern C++ without having a "bolted-on"
feel. Still, it will be very hard to ever displace C++, because _so much_ code
is currently written in C++ and C++ has proven to be a very good language for
code that needs to last decades.

~~~
adamnemecek
> Still, it will be very hard to ever displace C++, because so much code is
> currently written in C++ and C++ has proven to be a very good language for
> code that needs to last decades.

I'm pretty sure that Rust devs are aware of that which is why they made Rust
compatible with C/C++.

~~~
bjz_
The big issue is that C++ FFIs are notoriously hard to implement. Often C
wrappers are the only way to go (Rust has an excellent C FFI). As far as I
know, I think D is one of the best out there regarding C++ compatibility, but
it is still lacking.

------
halayli
I wish they add a new operator: "in" ... then it can be defined in maps and
whatnot for lookups: if (123 in x)

~~~
shin_lao
You're not thinking C++ish.

There is a wide range of algorithms to find/modify/replace data in containers.

Let's say you have a set of ints, doing what you want is the following:

    
    
        std::set<int> blah;
    
        // ... some stuff happens ...
    
        if (blah.find(123) != blah.end())
        {
        // ...
        }
    

Now, you're saying, "but my container doesn't have find!". Not a problem, you
can use std::find!

    
    
        std::vector<int> v;
    
        // ... some stuff happens ...
    
        if (std::find(v.begin(), v.end(), 123) != v.end())
        {
        // ...
        } 
    
    

Note that v can be ANYTHING, as long it supports forward iterators (which all
containers do).

Now you're saying, "but it's not very efficient! The complexity of find is
O(n)!"

True, true. If your container is sorted, you should use binary search O(log
n):

    
    
       if (std::binary_search(v.begin(), v.end(), 123))
       {
       // ...
       }
    

What's great about this is that it works on any container, provided it's
sorted.

Then, what you can do is write a metafunction that will call the member
function find() when it exists or use std::find() when there's none. This will
automatically, and at compile time, use the most efficient way to check for
the existence of an entry.

~~~
halayli
I am not talking about how I end up searching the container. I am talking
about the syntax. Besides, how a container is searched should be abstracted
away in the container's implementation and the algorithm should be documented.

Compare this syntax:

> if (std::find(v.begin(), v.end(), 123) != v.end())

To

> if (123 in v)

If in is an operator and overloaded by std::vector, then it's easy to
implement.

~~~
pfultz2
> If in is an operator and overloaded by std::vector, then it's easy to
> implement.

However, searching a `std::vector` is not really part of its implementation.
So, requiring every single range to overload an operator for trivial searching
is not good, especially since there are only a few containers that have non-
trivial searching.

Instead, the range-based find could be specialized for containers that have
non-trivial searching instead(perhaps it calls a `.find` method if available
otherwise it does trivial searching).

In [Linq]([http://pfultz2.github.io/Linq/](http://pfultz2.github.io/Linq/)),
the find is specialized for mapped containers and for strings(it doesn't check
for a `.find` method since that can't be done on msvc). So you can search a
`std::vector` like this:

    
    
        std::vector<int> v = { ... };
        auto it = v | linq::find(123);
    

And you can also search the keys of a map like this:

    
    
        std::map<int, std::string> m = { ... };
        auto it = m | linq::find(123);
    

Plus, it has a contains function, so you can do this:

    
    
        if (v | linq::contains(123))
    

Or this:

    
    
        if (m | linq::contains(123))
    

There really is no need for a new operator just for this, since a function
will suffice. However, if you really inclined to this, you could always write
your own [named operator]([https://github.com/klmr/named-
operator)(although](https://github.com/klmr/named-operator\)\(although) I
don't know if it would become standard):

    
    
        if (123 <in> v)

~~~
halayli
You can say the same thing for the new range based for loop in C++11.

------
sippeangelo
> 3781 - Single quotation mark as digit separator

Hold on a minute. Why is this even a thing? Do people really use HUGE numeric
literals and have so much trouble reading them that this is needed?

This just sounds like another parsing nightmare that really should belong in
syntax highlighting rather than exist as some obscure language feature.

~~~
jjoonathan
> Do people really use HUGE numeric literals

Yes. Engineering code uses numeric literals with many digits all the time.

> and have so much trouble reading them that this is needed?

Digit separators make digit omissions/additions much easier to spot. Imagine
spending a day trying to track down a "everything explodes" bug,
systematically eliminating numerical sources of error one by one, only to find
that the problem is a misspecified boundary condition that you didn't catch
the first time around because you were counting the number of zeros as opposed
to the number of digits.

    
    
        c = 3000'000'000 /*  m/s  */
    

^ I can spot _this_ out of the corner of my eye.

    
    
        c = 3000000000   /*  m/s  */
    

^ This? Not so much.

~~~
papaf
I prefer this alternative:

    
    
      c_millisecs = 50000 * 60 * 1000; // 50,000 minutes

~~~
jjoonathan
That only works for unit conversions where they're defined as ratios of each
other. Nature has physical constants and engineers have environmental and
design parameters that can't be written that way unless you constantly change
units, which is a bad idea in a language without built-in unit checking (most
of them).

------
greatsuccess
For the love of God, or some other entity you find holy or unholy.

Stop using this bastard of a language. Its an offront to software engineering
and must simply _die_

~~~
banachtarski
Do you play games? Do you play console games, or desktop games? Do these games
support 3D rendering? Soft shadows? Physically based lights? Pathfinding of
crowds of people or units? Literally hundreds of thousands of projectiles?
Networked replication? Leverage all the cores of your desktop/device/console
while doing the above? Support unique or specialized data structures? Execute
a runtime that _CAN 'T_ tolerate non-deterministic GC pauses?

I make games. What am I supposed to code that in? Fucking javascript? Ruby?
C#? Go stfu and die yourself. If you want to come up with a language that can
get the job fucking done than by all means, go for it and fail miserably.
Otherwise, stop using any of the products that leverage C++. We don't want
you.

~~~
greatsuccess
Im sorry your too much of a pussy to just write C.

~~~
epi8
Good compile-time dispatch is a relatively easy in C++, but damn-near
impossible in C. There are actual legitimate reasons to use C++.

------
puppetmaster3
I here by announce, that C++ next version will be called D! More links here:
[http://dlang.org](http://dlang.org)

