The “{}” syntax is new, but the concept is old. The “()” syntax always
worked, but it was ambiguous in most contexts except for member
initialization. I.e.:

template... class foo<typename T> {
  T bar;
  foo() {}   // leaves bar uninitialized if T is a base type
};
foo<int> test; // test.bar uninitialized

template... class foo2<typename T> {
  T bar;
  foo2() : bar() {}   // always initializes bar
};
foo2<int> test2;  // test2.bar == 0

The problem was in local variable context, “int x();” declares a function
returning int; so you had to write “int x = int();” which was annoying....
Now we have “int x{};”.



On Fri, Oct 11, 2013 at 12:08 PM, Stephen Tu <notifications@github.com>wrote:

> In base_txn_btree.h:
>
> > @@ -213,7 +216,7 @@ class base_txn_btree {
> >      key_writer.fully_materialize(true, t.string_allocator());
> >
> >    // search the underlying btree to map k=>(btree_node|tuple)
> > -  typename concurrent_btree::value_type underlying_v;
> > +  typename concurrent_btree::value_type underlying_v{};
>
> I didn't realize there was such a thing! I've wanted something like this
> for a while... is this new?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/stephentu/silo/pull/8/files#r6919256>
> .
>