Blog

Quick Q: Does unordered_map<string,MyClass>::erase() destroy my MyClass objects?—SO

Quick A: No, but unordered_map<string, unique_ptr<MyClass>>::erase and unordered_map<string, shared_ptr<MyClass>>::erase do.

Today on SO:

std::unordered_map<std::String, myClass*> -- does std::unordered_map::erase() call myClass' DTor?

Assume I have some unordered_map of pointers to class instances, would erasing an object from that map also delete the instance?

(rewording the question:) If I wanted to delete that instance, which version would be right?

if(it != map.end())
{
    delete it->second;
    map.erase(it);
}

or simply

if(it != map.end())
    map.erase(it);

?

Quick Q: Is there an alternative to PC-Lint that supports C++14?—StackOverflow

It's not often we run a link to a SO article in the Product section, but this is a useful product question.

Alternative for PC-Lint supporting C++14 (Visual Studio 2013)

I am using PC-Lint for quite some time with very good results.

The last year however, I noticed that PC-Lint cannot keep up with the new C++ standards. E.g. range-based for-loops, variadic templates, make_unique, ... which are all constructions supported by Visual Studio 2013, aren't recognized by PC-Lint.

The result is that my code is now filled with lint-comments to disable checking on blocks of code using these constructions. This means:

  • less readable code
  • I'm almost spending more time updating my lint-comments that actually writing code

Is there an alternative (free or commercial) for PC-Lint on Windows that can keep up with the recent C++ standards?

A pair of articles on advanced template mechanics—Eli Bendersky and Eric Niebler

If you're a very advanced C++ developer with an appetite for template mechanics, these two articles that were posted in the past 24 hours may interest you.

Note: The vast majority of C++ developers don't need to know this, but very advanced developers will find the material and the techniques interesting.

SFINAE and enable_if

by Eli Bendersky

Customization Point Design in C++11 and Beyond

by Eric Niebler

How Microsoft is taking on the cross-platform challenge with Office—Mary Jo Foley

zaika-office.PNGModern C++, modern apps:

How Microsoft is taking on the cross-platform challenge with Office

by Mary Jo Foley

Summary: Microsoft's Office team has a new approach designed to allow it to share more of Office's code across not just Windows, but also Android, iOS and the Web.

Note: This is a 50-minute version of the same talk given at CppCon in two one-hour sessions. After presenting this at CppCon, Igor was invited to present the information also at Facebook's @Scale.

See also Dropbox's CppCon talk about how Dropbox uses a similar architecture, and moved to C++ to enable a single cross-platform source base after initially having written separate apps in Java for Android and Objective-C for iOS.

From the article:

Zaika talked about Microsoft's Office cross-platform architecture strategy at the recent Facebook @Scale conference. ... In his 50-minute session, Zaika detailed how Microsoft is building Office across Windows, Apple, Android and the Web by using C++. ...

The goal is to maintain a shared core of intellectual property — the guts of Office — all written in C++ and keep that shared core as large as possible. By doing this, risks of document corruption are reduced. On top of that core, there is a set of native UX application programming interfaces. ...

The goal of "write once, run anywhere" which technologies like Java, Flash and HTML5 were designed to try to solve by pushing the level of abstraction as low as possible or making application programming interfaces (APIs) very broad sounded good, Zaika said, but ended up creating impedance mismatch. Compatibility and interoperability problems, among others, arose. "Either you blew up, or the OS (operating system) blew up," Zaika said. ...

With a common C++ core, a thin native UX layer and evolving PALs, Microsoft is building its Office apps so they work on different OSes with fairly little tweaking required. Zaika cited PowerPoint as an example, noting that only four percent of its tens of millions of lines are unique to the WinRT/Universal version of Office (the touch-first Office release some of us have been calling "Gemini"). If the XAML code is excluded, the amount of shared code is 98.6 percent he said. The PowerPoint for Android code base includes 95 percent shared code, Zaika said.

Meeting C++ is sold out!

Last week the last ticket for Meeting C++ has been sold:

Meeting C++ is sold out for now

by Jens Weller

from the Article:

Ticket sales have been strong all summer long, and those who have yet not got their ticket will have to wait, maybe even for next year. There might be a second batch of tickets, which will not be more then 10-30 tickets released at the beginning of November. But for now, we are at almost 300 Attendees for Meeting C++! This includes the 50 Students, the speakers, the staff and all sold tickets.

A Video Interview with Herb Sutter on C++ Standards—Brian Overland

sutter-overland.PNGAt CppCon last month, InformIT recorded this video interview. It has now been posted: 

A Video Interview with Herb Sutter on C++ Standards

with Brian Overland

From the synopsis:

Herb Sutter ... talks with Brian Overland about how the standards committee evaluates proposals, the importance of being egoless, how to submit a proposal to the standards committee, why the committee decided to update the standard every three years, and the adoption of C++ in cross-platform mobile apps.

Today: Community Planning Session

Today is the community planning session:

This Thursday: Community Planning Session

We'll meet at #meetingcpp in freenode at 17:00 CET!

From the article:

For the second time, we'll have the communtiy planning session happening at the freenode channel #meetingcpp. It will officially last one hour, but most likely be again the full evening a very busy chat. Last time we had guests from Europe, the US and Brazil...

Pre-Urbana mailing available

The pre-Urbana mailing of new standards papers is now available.

Many of the papers in the mailing have already been published individually on this blog.

NOTE: A number of these papers have already been publicized on this blog. This is the complete list including ones not previously publicized.

WG21 Number Title Author Document Date Mailing Date Previous Version Subgroup Disposition
2014-10-pre-Urbana
N4122 AGENDA, PL22.16 Meeting No. 64, WG21 Meeting No. 59, November 3-8, 2014 – Urbana-Champaign, IL Stephen D. Clamage 2014-08-28 2014-10      
N4123 Improvements to the Concurrency Technical Specification A. Laksberg, V. Escriba 2014-10-10 2014-10 N4107 Concurrency  
N4124 Toward More Expressive Iterator Tags Bill Seymour 2014-09-11 2014-10 N4068 Library  
N4125 2014-09 WG21/SG1 Meeting Information Herb Sutter 2014-07-17 2014-10   Concurrency  
N4126 Explicitly defaulted comparison operators Oleg Smolsky 2014-07-29 2014-10 N4114 Evolution  
N4127 Checked-dereference conditions Eelis van der Weegen 2014-07-20 2014-10   Evolution  
N4128 Ranges for the Standard Library, Revision 1 E. Niebler, S. Parent, A. Sutton 2014-10-10 2014-10   Library  
N4129 Source-Code Information Capture Robert Douglas 2014-10-10 2014-10 N3972 Library  
N4130 Pad Thy Atomics JF Bastien, O. Giroux 2014-09-01 2014-10   Concurrency  
N4131 explicit should never be implicit Filip Roséen 2014-08-09 2014-10   Evolution  
N4132 Contiguous Iterators Jens Maurer 2014-09-10 2014-10   Library  
N4133 Cleanup for exception-specification and throw-expression Jens Maurer 2014-09-10 2014-10   Core  
N4134 Resumable Functions v.2 G. Nishanov, J. Radigan 2014-10-10 2014-10 N3977 Concurrency  
N4135 Language Support for Runtime Contract Validation (Revision 8) J. Lakos, A. Zakharov, A. Beels, N. Meyers 2014-10-09 2014-10 N4075 Evolution  
N4136 C Concurrency Challenges Draft M. Batty, P. Sewell, et al. 2014-10-13 2014-10   Concurrency  
N4137 Business Plan and Convener's Report Herb Sutter 2014-08-25 2014-10      
N4138 Editor's Report -- Working Draft, Standard for Programming Language C++ Richard Smith 2014-10-07 2014-10      
N4139 Editor's Report -- Programming Languages -- C++ Richard Smith 2014-10-07 2014-10      
N4140 Working Draft, Standard for Programming Language C++ Richard Smith 2014-10-07 2014-10 N3936    
N4141 Programming Languages — C++ Richard Smith 2014-09-02 2014-10 N3937    
N4142 Atomic Operations on a Very Large Array Carter Edwards 2014-09-08 2014-10   Concurrency  
N4143 Executors and schedulers, revision 4 Chris Mysen 2014-10-11 2014-10 N3785 Concurrency  
N4144 Searching and Manipulation of Parameter Packs B. Seymour, S. Lavavej 2014-09-11 2014-10 N4115 Library  
N4145 Data-Invariant Functions Jens Maurer 2014-09-26 2014-10   Library  
N4146 Disposition of Comments, ISO/IEC DIS 14882 C++ 2014 Barry Hedquist 2014-09-23 2014-10      
N4147 Inline variables, or encapsulated expressions David Krauss 2014-09-15 2014-10   Evolution  
N4148 Disallowing Inaccessible Operators From Trivially Copyable Matheus Izvekov 2014-09-24 2014-10   Evolution  
N4149 Categorically qualified classes David Krauss 2014-09-25 2014-10   Evolution  
N4150 Alias-Set Attributes: Toward restrict-like aliasing semantics for C++ H. Finkel, H. Tong, et al. 2014-10-10 2014-10 N3988 Evolution  
N4151 TriviallyCopyable reference_wrapper Agustín Bergé 2014-08-08 2014-10   Library  
N4152 uncaught_exceptions Herb Sutter 2014-09-30 2014-10 N3614 Evolution  
N4153 2015-02 LWG Meeting Invitation and Information Nico Josuttis 2014-10-03 2014-10      
N4154 Operator assert David Krauss 2014-09-30 2014-10   Evolution  
N4155 Non-member size() and more (Revision 1) Riccardo Marcangelo 2014-09-28 2014-10 N4017 Library  
N4156 Light-Weight Execution Agents Revision 3 Torvald Riegel 2014-10-10 2014-10 N4016 Concurrency  
N4157 Relaxing Packaging Rules for Exceptions Thrown by Parallel Algorithms A. Robison, J. Hoberock, A. Laksberg 2014-10-02 2014-10   Concurrency  
N4158 Destructive Move (Rev 1) Pablo Halpern 2014-10-12 2014-10 N4034 Library  
N4159 std::function and Beyond G. Romer, R. Perepelitsa 2014-10-10 2014-10   Library  
N4160 Value constraints Andrzej Krzemieński 2014-10-03 2014-10   Evolution  
N4161 Uniform Container Erasure (Revision 1) Stephan T. Lavavej 2014-10-09 2014-10 N4009 Library  
N4162 Atomic Smart Pointers, rev. 1 Herb Sutter 2014-10-06 2014-10 N4058 Concurrency  
N4163 Agenda and Meeting Notice for WG21 Telecon Meeting Herb Sutter 2014-10-06 2014-10      
N4164 Forwarding References H. Sutter, B. Stroustrup, G. Dos Reis 2014-10-06 2014-10   Evolution  
N4165 Unified Call Syntax Herb Sutter 2014-10-04 2014-10      
N4166 Movable initializer lists David Krauss 2014-10-06 2013-10   Evolution  
N4167 Transform Reduce, an Additional Algorithm for C++ Extensions for Parallelism G. Mercer, A. Bergé, H. Kaiser 2014-10-10 2014-10   Concurrency  
N4168 Removing auto_ptr Billy Baker 2014-10-02 2014-10   Library  
N4169 A proposal to add invoke function template (Revision 1) Tomasz Kamiński 2014-08-22 2014-10 N3727 Library  
N4170 Extend INVOKE to support types convertible to target class (Revision 1) Tomasz Kamiński 2014-08-12 2014-10 N3719 Library  
N4171 Parameter group placeholders for bind Tomasz Kamiński 2014-10-05 2014-10   Library  
N4172 Named arguments E. Akhgari, B. Ballo 2014-10-07 2014-10   Evolution  
N4173 Operator Dot B. Stroustrup, G. Dos Reis 2014-10-11 2014-10   Evolution  
N4174 Call syntax: x.f(y) vs. f(x,y) Bjarne Stroustrup 2014-10-11 2014-10   Evolution  
N4175 Default comparisons Bjarne Stroustrup 2014-10-11 2014-10   Evolution  
N4176 Thoughts about Comparisons Bjarne Stroustrup 2014-10-11 2014-10   Evolution  
N4177 Multidimensional bounds, index and array_view, revision 4 Ł. Mendakiewicz, H. Sutter 2014-10-06 2014-10 N4087 Library  
N4178 Proposed resolution for Core Issue 330: Qualification conversions and pointers to arrays of pointers Jens Maurer 2014-10-07 2014-10   Core  
N4179 Transactional Memory Support for C++: Wording (revision 2) Jens Maurer 2014-10-10 2014-10 N3999 Core/Library  
N4180 SG5 Transactional Memory Support for C++ Update M. Wong, V. Luchangco, J. Maurer, et al. 2014-10-10 2014-10 N3999 Evolution  
N4181 Transactionalizing the C++ Standard Library Updates M. Wong, J. Maurer, M. Spear, J. Gottschlich, T. Riegel, et al.   missing N4000 Library  
N4182 SG5: Transactional Memory (TM) Meeting Minutes 2014/07/14-2014/10/06 Michael Wong 2014-10-10 2014-10      
N4183 Contiguous Iterators: Pointer Conversion & Type Trait Nevin Liber 2014-10-10 2014-10 N3884 Library  
N4184 SIMD Types: The Vector Type & Operations Matthias Kretz 2014-10-10 2014-10 N3759 Concurrency  
N4185 SIMD Types: The Mask Type & Write-Masking Matthias Kretz 2014-10-10 2014-10   Concurrency  
N4186 Supporting Custom Diagnostics and SFINAE Matthias Kretz 2014-10-10 2014-10   Evolution  
N4187 C++ Ostream Buffers L. Crowl, P. Sommerlad 2014-10-08 2014-10 N4069 Library  
N4188 Proposal for classes with runtime size L. Deniau, A. Naumann 2014-10-01 2014-10   Evolution  
N4189 Generic Scope Guard and RAII Wrapper for the Standard Library P. Sommerlad, A. Sandoval 2014-10-08 2014-10 N3949 Library  
N4190 Removing auto_ptr, random_shuffle(), And Old <functional> Stuff Stephan T. Lavavej 2014-10-09 2014-10   Library  
N4191 Folding expressions A. Sutton, R. Smith 2014-10-07 2014-10   Evolution  
N4192 C++ Standard Core Language Active Issues, Revision 91 William M. Miller 2014-10-13 2014-10 N4091 Core  
N4193 C++ Standard Core Language Defect Reports and Accepted Issues, Revision 91 William M. Miller 2014-10-13 2014-10 N4092 Core  
N4194 C++ Standard Core Language Closed Issues, Revision 91 William M. Miller 2014-10-13 2014-10 N4093 Core  
N4195 std::synchronic<T> O. Giroux, C. Edwards 2014-10-07 2014-10   Concurrency  
N4196 Attributes for namespaces and enumerators Richard Smith 2014-10-06 2014-10   Evolution  
N4197 Adding u8 character literals Richard Smith 2014-10-06 2014-10   Core  
N4198 Allow constant evaluation for all non-type template arguments Richard Smith 2014-10-06 2014-10   Evolution  
N4199 Minutes of Sept. 4-5, 2014 SG1 meeting in Redmond, WA Hans-J. Boehm 2014-10-10 2014-10      
N4200 Feature-testing recommendations for C++ Clark Nelson 2014-10-08 2014-10 N4030    
N4201 Alignment Helpers for C++ Matthew Fioravante 2014-08-20 2014-10   Library  
N4202 Strongly Typed Bitset Matthew Fioravante 2014-08-20 2014-10   Library  
N4203 Fast ASCII Character Manipulation Matthew Fioravante 2014-08-20 2014-10   Library  
N4204 C++ Latches and Barriers A. Mackintosh, O. Giroux 2014-08-06 2014-10 N3998 Concurrency, Library  
N4205 Working Draft, C++ Extensions for Concepts Andrew Sutton 2014-10-10 2014-10 N4040 Core  
N4206 C++ Standard Evolution Active Issues List (Revision R09) Ville Voutilainen 2014-10-09 2014-10 N4101 Evolution  
N4207 C++ Standard Evolution Completed Issues List (Revision R09) Ville Voutilainen 2014-10-09 2014-10 N4102 Evolution  
N4208 C++ Standard Evolution Closed Issues List (Revision R09) Ville Voutilainen 2014-10-09 2014-10 N4103 Evolution  
N4209 A Proposal to Add a Const-Propagating Wrapper to the Standard Library J. Coe, R. Mill 2014-10-09 2014-10 N4057 Library  
N4210 IBM comment on preparing for a Trigraph-adverse future in C++17 M. Wong, H. Tong, R. Bhakta, D. Inglis 2014-10-10 2014-10   Evolution  
N4211 File System TS Active Issues List (Revision R3) Beman Dawes 2014-10-11 2014-10 N4095 Filesystem  
N4212 File System TS Closed Issues List (Revision R3) Beman Dawes 2014-10-11 2014-10 N4096 Filesystem  
N4213 File System TS Defect Report List (Revision R3) Beman Dawes 2014-10-11 2014-10 N4097 Filesystem  
N4214 A Module System for C++ (Revision 2) G. Dos Reis, M. Hall, G. Nishanov 2014-10-13 2014-10 N4047 Modules  
N4215 Towards Implementation and Use of memory_order_consume P. McKenney, T. Riegel, J. Preshing 2014-10-05 2014-10 N4036 Concurrency  
N4216 Out-of-Thin-Air Execution is Vacuous P. McKenney, A. Jeffrey, A. Sezgin 2014-10-10 2014-10   Concurrency  
N4217 std::rand replacement Zhihao Yuan 2014-10-08 2014-10 N3796 Library  
N4218 Variant: a typesafe union Axel Naumann 2014-09-24 2014-10   Library  
N4219 Fixing the specification of universal-character-names (rev. 2) David Krauss 2014-10-10 2014-10 N3881 Undefined Behavior  
N4220 An update to the preprocessor specification (rev. 2) David Krauss 2014-10-10 2014-10 N3882 Undefined Behavior  
N4221 Generalized lifetime extension David Krauss 2014-10-10 2014-10   Evolution  
N4222 Minimal Additions to the Array View Library for Performance and Interoperability R. ter Borg, J. Perla 2014-10-09 2014-10   Library  
N4223 Response To: Let return {expr} Be Explicit V. Voutilainen, M. Kilpeläinen, J. Wakely 2014-10-10 2014-10 N4094 Evolution  
N4224 Supplements to C++ Latches A. Mackintosh, A. Berkan 2014-10-10 2014-10   Concurrency  
N4225 Towards uniform handling of subobjects Ville Voutilainen 2014-10-10 2014-10   Concurrency  
N4226 Apply the [[noreturn]] attribute to main as a hint to eliminate global object destructor calls D. Diaz, E. Bringas, D. Gutson, J. Maurer 2014-10-10 2014-10   Reflection  
N4227 Cleaning-up noexcept in the Library (Rev 2) Nicolai Josuttis 2014-10-10 2014-10 N4002 Library  
N4228 Refining Expression Evaluation Order for Idiomatic C++ G. Dos Reis, H. Sutter, J. Caves 2014-10-13 2014-10   Evolution  
N4229 Pointer Ordering Gabriel Dos Reis 2014-10-13 2014-10   Evolution  
N4230 Nested namespace definition (revision 2) R. Kawulak, A. Tomazos 2014-10-10 2014-10 N4026 Evolution  
N4231 Terms and definitions related to "threads" T. Riegel, C. Nelson 2014-10-10 2014-10   Concurrency  
N4232 Stackful Coroutines and Stackless Resumable Functions Nat Goodspeed 2014-10-13 2014-10   Concurrency  
N4233 A Class for Status and Optional Value L. Crowl, C. Mysen 2014-10-10 2014-10   Library  
N4234 0-overhead-principle violations in exception handling - part 2 Daniel Gutson 2014-10-10 2014-10   Evolution  
N4235 Selecting from Parameter Packs Daveed Vandevoorde 2014-10-10 2014-10   Evolution  
N4236 A compile-time string library template with UDL operator templates Michael Price 2014-10-10 2014-10   Library  
N4237 Language Extensions for Vector loop level parallelism R. Geva, C. Nelson 2014-10-10 2014-10   Concurrency  
N4238 An Abstract Model of Vector Parallelism Pablo Halpern 2014-10-13 2014-10   Concurrency  
N4239 Defaulted Comparison Using Reflection A. Tomazos, M. Spertus 2014-10-12 2014-10   Reflection, Evolution  
N4240 Improved insertion interface for unique-key maps (Revision 2) Thomas Köppe 2014-10-11 2014-10 N3873 Library  
N4241 A proposal to add shared_mutex (untimed) (Revision 3) Gor Nishanov 2014-10-10 2014-10 N3995 Concurrency  
N4242 Executors and Asynchronous Operations, Revision 1 Christopher Kohlhoff 2014-10-13 2014-10 N4046 Concurrency  
N4243 Executors and Asynchronous Operations Christopher Kohlhoff 2014-10-13 2014-10 N4046 Concurrency  
N4243 Networking Library Proposal (Revision 2) Christopher Kohlhoff 2014-10-13 2014-10 N2175 Networking, Library  
N4244 Resumable Lambdas: A language extension for generators and coroutines Christopher Kohlhoff 2014-10-13 2014-10   Concurrency  
N4245 C++ Standard Library Active Issues List (Revision R90) Alisdair Meredith 2014-10-13 2014-10 N4117 Library  
N4246 C++ Standard Library Defect Report List (Revision R90) Alisdair Meredith 2014-10-13 2014-10 N4118 Library  
N4247 C++ Standard Library Closed Issues List (Revision R90) Alisdair Meredith 2014-10-13 2014-10 N4119 Library  
N4248 Library Preconditions are a Language Feature Alisdair Meredith 2014-10-12 2014-10   Evolution  
N4249 Networking Primitives: std::experimental::network::htonl Considered Harmful A. Meredith, J. Burley, A. Martin, D. Chisnall, et al. 2014-10-09 2014-10   Library  

N4241: A proposal to add shared_mutex (untimed), (Revision 3)—Gor Nishanov

A new WG21 paper is available. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: N4241

Date: 2014-10-10

A proposal to add shared_mutex (untimed), (Revision 3)

by Gor Nishanov

Excerpt:

At the Issaquah ISO C++ meeting of 2014 shared_mutex was renamed to shared_timed_mutex per proposal N3891 to follow the naming precedent set by timed_mutex and recursive_timed_mutex and to leave room for an untimed shared_mutex which can be more efficient on some platforms than shared_timed_mutex.

This paper introduces a shared_mutex type without timed locking requirement. This paper only includes the proposed wording. For background for shared locking please refer to N3568, N3659 and N3891.
This revision is a minor edit of an earlier paper N3995 that adds a missing unlock() and native_handle() member functions.