Skip to content
0:00 / 0:00

#defaultarguments#cppcon#functiontemplates

CppCon 2017: Michael Price “Function default arguments: Slingshot or Shotgun?”

CppCon

189K subscribers • 101 videos on Hallway • Conference channel

YouTube
  • Recommended by 1 person: 1 on Stack Overflow and its sister sites.
  • Presented by Michael Price, Senior Software Engineer at Synopsys
  • Linked in the descriptionCppCon/CppCon2017

Advanced. Deep dive for people who know the field.

5.3K views9 years ago1 recommendation

Programming languagesC++Language design and type systems

Michael Price explores the complex and often surprising behavior of function default arguments in C++.

CppCon.org — Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2017 — On the surface, function parameter default arguments seem like a very simple feature of the C++ language. This session explores how (not) true that is. If you like the dark corners of C++, you will come away with a new appreciation for this innocent looking syntactic sugar. Otherwise, you will have at least informed yourself on how not to blow your foot off with what looks like a slingshot. — Michael Price: Synopsys, Inc., Senior Software Engineer Michael Price has developed and taught C++ for more than a decade and has been an active participant in WG21 since 2014, allocating most of his committee-time to EWG and the Reflection Study Group. He professes interest in making C++ "safer" to use through language and library design, automation, testing, and education. His past work includes enterprise-grade screen sharing applications, ABI-safe C++ component design, network protocol design, software development utilities, large-scale build and test automation, C/C++ compiler front-end development for static analysis tools, and a smidge of management experience. — Videos Filmed & Edited by Bash Films: BashFilms.com Work at Hudson River Trading (HRT): tinyurl.com/safxfctf --- Videos Filmed & Edited by Bash Films: BashFilms.com

Why it's here

1 person recommends this

What people say. Recommended as an excellent deep dive into the tricky corner cases of C++ default arguments.

Michael Priceon Stack Overflow • Recommends

On “Why the warning for default arguments?”

There are several odd corner cases when it comes to default arguments on function parameters. Here is a presentation from CppCon 2017 detailing a lot of tricky behavior. link to this video To summarize the main points: Redeclarations cause potentially confusing behavior The default arguments used in virtual function calls are not determined by the function called, but by the static type. Default arguments on function templates can potentially look ill-formed, but may compile as long as they are not instantiated. Of course, for your case of a non-template constructor, they are fairly innocuous. It can’t be overridden or redeclared (although an out-of-line definition might cause you possible…