Feeds:
Posts
Comments

Anubhav asked:

An interesting question has come up in our project while debating operator new as a class member function. Specifically, the question is about whether such a class should be allowed to be instantiated on stack. The understanding is that a class providing its own operator new would likely have special layout considerations which would not be met if the object of such a class is instantiated locally.

The class specific operator new is used when allocating on the heap, but objects can still be allocated on the stack. The only way I know to prevent an object from being instantiated on the stack is by forcing creation through a factory function that always allocates on the heap, for example:

#include <memory>

class X {
// make all ctors private
X();
X(const X&);
// and any other ctors go here

public:
// Factory function (or it could be a nonmember friend)
static auto make( /*…*/ ) { return std::unique_ptr<X>(new X( /*…*/ )); }

// the usual public member functions go here
};

int main()
{
X x; // error
auto x2 = X::make(); // ok
}

A lot of you have been asking me whether there will be some sort of C++ and Beyond in 2014. Also, over the past few years many of you have also asked me if there will ever be a C&B outside North America. I’m pleased to report that we are doing a ‘European Encore’ event reprising previous C&B material.

Today on the C&B blog, Scott announced that yes, there will be a “C++ and Beyond Road Show” in 2014… in Germany! Note that this is different from previous C&B’s because the purpose is to largely repeat the C&B 2013 program at an event in Europe, in order to make it accessible to people who were not able to fly to North America for previous C&Bs. So think of it as a “C&B Encore” or “C&B Greatest Hits Roadshow Edition.”

From the announcement:

You can think of this event as the C&B Road Show, because the organization is a little different from how we’ve done things in the past:

  • Most of the talks will be updated versions of the presentations we gave at C&B 2013. (See the schedule here.) If you were unable to attend C&B this past December, this is your chance to see what you missed.
  • A group dinner on the first day is included.
  • The schedule is a bit compressed, so some aspects of previous C&Bs are not present. These include group breakfasts and evening discussion sessions.

For this event, we’ve partnered with QA Systems, the same company I’ve worked with since 1999 on technical seminars in Europe. They’ll be handling registration and all other logistical and administrative aspects of the event. Consult their web page for C&B 2014 for all the details of this event.

This will be the only C&B in 2014, so we hope to see you in Stuttgart at the end of September for the first-ever C&B in Europe!

For those of you who have attended C&B before and others who’ve been asking me whether there will be a “regular” C++ and Beyond in North America this year with new material, the answer is not this year; we don’t do a new one every year, and we’re skipping this year. If you are looking for a C++ event in North America with new material, do check out CppCon on September 7-12 in the Seattle area – I am currently planning to create some new talks for CppCon, as well as to repeat some of my C&B talks there. I hear tell that Scott and Andrei might be there too, as well as dozens and dozens of our closest speaker friends.

I’m looking forward to seeing many of you at C&B Europe and CppCon this fall!

That was fast!

Tim just added this comment on the GotW #3 Solution blog post from last year:

Are you sure you can use auto in lambda like this?
I can not compile the code and I’m pretty sure auto does not work here.

If you mean auto as a lambda parameter type, such as

[](auto& s){ use(s); }

then yes, it’s (now) legal): That’s a new feature in currently-being-finalized C++14 standard, and it’s called “generic lambdas.” It means that the compiler-generated closure object’s

operator()

is a template, so you can call the same closure object multiple times with different types and get the templated operator stamped out for each set of types it’s called with.

Major compilers are now adding support for this. As of this writing, all of GCC, Clang, and Visual C++ have implemented the basic feature and you can get it in CTP/preview/alpha releases of each, such as GCC or Clang trunk, or Visual C++ November 2013 CTP. I can’t remember offhand which of those compilers have shipped an official release since adding it (VC++ has not) but they’ll all have it in their next released versions.

By the way, isn’t it wonderful that, for the first time in the history of C++, multiple major compilers are in pretty good sync like this, both with each other and with the standard? I think that’s awesome.

If you’re at Build in San Francisco tomorrow afternoon, I invite you to swing by and spend an hour with us in session 2-661:

Modern C++: What you need to know

by Herb Sutter

Build 2014, Room 2005
2:30-3:30 pm, Thursday April 3, 2014

If you’re new to C++, this talk is aimed directly at you. I was asked to give a “foundational talk” about C++, and I decided that meant I should focus on addressing two questions that I get a lot these days:

  • FAQ #1 (1-2 slides): When should I use C++ compared to another language – on all platforms in general, and on Microsoft platforms in particular?
  • FAQ #2 (lots of slides): What should I know about C++ if I’m a {Java|C#|JavaScript|Python|…} developer?

Even if you’re a seasoned C++ developer, there are some nuggets and data points in the middle of the talk that I think you will find useful in your own work, and I hope that the talk as a whole will be helpful to you in providing a way to explain C++’s value proposition and give (or link to) an answer when someone asks you FAQ #2.

I think it will be recorded, and will post a link here when the recording is available.

I look forward to seeing many of you there tomorrow afternoon.

More news about the first annual CppCon that was announced last week:

CppCon 2014 Call for Submissions

CppCon is the annual, week-long face-to-face gathering for the entire C++ community. The conference is organized by the C++ community for the community and so we invite you to present.

Have you learned something interesting about C++, maybe a new technique possible in C++11? Or perhaps you have implemented something cool related to C++, maybe a new C++ library? If so, consider sharing it with other C++ enthusiasts by giving a talk at CppCon 2014. Submissions deadline is May 15 with decisions sent by June 13. For topic ideas, possible formats, and submission instructions, see the Submissions page.

Note that speakers get free registration to attend the whole conference.

I strongly encourage you to present – not “even if” you’ve never presented before, but “especially if” you haven’t. At 5 days x ~5 tracks x ~6 full-length talks per day, this is a big conference with a lot of room for half-length (30 min), full-length (60 min) and multi-hour formal talks (this is in addition to Lightning Talks, which will be arranged later).

For an idea of talks, from the Submissions page:

We are open to any topic that will be of interest to a mainstream C++ audience. Below are some ideas.

  • C++11
  • C++ libraries and frameworks of general interest
  • C++14 and new standardization proposals
  • Parallelism/multi-processing
  • Concepts and generic programming
  • Functional programming
  • High performance computing
  • Software development tools, techniques, and processes for C++
  • Practical experiences using C++ in real-world applications
  • Industry-specific perspectives: mobile and embedded systems, game development, high performance trading, scientific programming, robotics, etc.

I know a number of people who are already planning to submit talks, and I am certain we will get talks on all these topics, and likely more.

As for me, I’m going to go propose a talk on lock-free programming now… everyone should have fun with lock-free mail slots and linked lists, and know when to worry about the ABA problem (and know how to solve it in portable C++11 code).

What should you do next?

If you have a talk idea, run don’t walk to submit a talk – but don’t register for the conference yet as you will get free registration for the conference if your talk is accepted.

Otherwise, register today! The first 100 to register get the Super Early Bird rate of $695 for the whole conference, and registration got off to a strong start since it opened last week – a good number of first-100 places are still available. This is the coolest and most informative event for C++ in nearly 20 years, and whether you’re a C++ novice or an expert you are going to have a great time and learn a lot of practical information and skills you can use on your project today.

I’m really excited about this event!

Note that the first 100 registrations get a big discount – pasting from the “registration” page:

Regular registration fee is $995 but the first 100 attendees can take advantage of Super Early Bird registration and pay only $695. After that, the Early Bird registration fee is $845 and is valid until the 1st of June. …

The announcement went live four hours ago, and the first registrations have already started to come in.

The full text of today’s announcement follows:

 

CppCon 2014 Registration Open

Opening Keynote by Bjarne Stroustrup
September 7–12, 2014
Bellevue, Washington, USA

Registration is now open for CppCon 2014 to be held September 7–12, 2014 at the Meydenbauer Center in Bellevue, Washington, USA. The conference will start with the keynote by Bjarne Stroustrup titled “Make Simple Tasks Simple!

CppCon is the annual, week-long face-to-face gathering for the entire C++ community. The conference is organized by the C++ community for the community. You will enjoy inspirational talks and a friendly atmosphere designed to help attendees learn from each other, meet interesting people, and generally have a stimulating experience. Taking place this year in the beautiful Seattle neighborhood and including multiple diverse tracks, the conference will appeal to anyone from C++ novices to experts.


What you can expect at CppCon:

  • Invited talks and panels: the CppCon keynote by Bjarne Stroustrup will start off a week full of insight from some of the world’s leading experts in C++. Still have questions? Ask them at one of CppCon’s panels featuring those at the cutting edge of the language.
  • Presentations by the C++ community: What do embedded systems, game development, high frequency trading, and particle accelerators have in common? C++, of course! Expect talks from a broad range of domains experts focused on practical C++ techniques, libraries, and tools.
  • Lightning talks: Get informed at a fast pace during special sessions of short, less formal talks. Never presented at a conference before? This is your chance to share your thoughts on a C++-related topic in an informal setting.
  • Evening events and “unconference” time: Relax, socialize, or start an impromptu coding session.

CppCon’s goal is to encourage the best use of C++ while preserving the diversity of viewpoints and experiences, but other than that it is non-partisan and has no agenda. The conference is a project of the Standard C++ Foundation, a not-for-profit organization whose purpose is to support the C++ software developer community and promote the understanding and use of modern, standard C++ on all compilers and platforms.

Follow

Get every new post delivered to your Inbox.

Join 2,142 other followers