ODB C++ ORM 2.4.0 Released, Adds Bulk Operations Support

ODB C++ ORM 2.4.0 Released, Adds Bulk Operations Support

by Boris Kolpackov

ODB is an open source object-relational mapping (ORM) system for C++. It allows you to persist C++ objects to a relational database without having to deal with tables, columns, or SQL and without manually writing any of the mapping code.

Major new features in this release:

  • Support for bulk operations in Oracle and SQL Server. Bulk operations can be used to persist, update, or erase a range of objects using a single database statement execution which often translates to a significantly better performance.
  • Ability to join and load one or more complete objects instead of, or in addition to, a subset of their data members with a single SELECT statement execution (object loading views).
  • Support for specifying object and table join types in views (LEFT, RIGHT, FULL, INNER, or CROSS).
  • Support for calling MySQL and SQL Server stored procedures.
  • Support for defining persistent objects as instantiations of C++ class templates.

A more detailed discussion of these features can be found on the blog. For the complete list of new features in this version see the official release announcement.

ODB is written in portable C++ (both C++98/03 and C++11 are supported) and you should be able to use it with any modern C++ compiler. In particular, we have tested this release on GNU/Linux (x86/x86-64/ARM), Windows (x86/x86-64), Mac OS X (x86/x86_64), and Solaris (x86/x86-64/SPARC) with GNU g++ 4.2.x-5.x, MS Visual C++ 2005, 2008, 2010, 2012, and 2013, Sun Studio 12u2, and Clang 3.x.

The currently supported database systems are MySQL, SQLite, PostgreSQL, Oracle, and SQL Server. ODB also provides optional profiles for Boost and Qt, which allow you to seamlessly use value types, containers, and smart pointers from these libraries in your persistent classes.

More information, documentation, source code, and pre-compiled binaries are available on the project's page.

How do I write complex initialization?--Stack Overflow

Quick A: Initialize it using a lambda that’s invoked immediately.

Recently on SO:

Best practice for declaring variable without initialising it, so auto is unavailable

I want to declare two variables of the same type, and have the compiler figure out the types. However I don't want to initialise one of the variables until later. I don't think I can use auto here, so what's the best option?

std::vector<int> v;

// `start` and `end` should be the same type
auto start = v.begin();
??? end;

// complicated code to assign a value to `end` (i.e. putting
// the code in a function or using ?: is not practical here) 
if (...) {
    end = ...;
} else {
    end = v.end();
}

What's the best way to tell the compiler that end should be the same type as start, but without having to initialise the variable?

auto start = v.begin(), end;  // Doesn't work, `end` has to be initialised
decltype(start) end;          // Does work, but not sure if it's best practice

Update

A couple of comments have suggested ways that would work in certain situations, so I am clarifying my situation here:

std::vector<int> v;
int amount = 123;

// `start` and `end` should be the same type
auto start = v.begin();
??? end;

// code to assign a value to `end`
if (amount) {
    end = start + amount;
    amount = 0;
} else {
    end = v.end();
}

I believe a lamda function would be trickier here, because amount is being reset to 0 after end is calculated, so in a lamda function that calculates a value for end, amount = 0 would have to come after the return statement. The only option would be to create more local variables, which would incur an (admittedly tiny) performance penalty.

The Rule of Zero revisited: The Rule of All or Nothing--Arne Mertz

In this article you will find a new rule of thumb:

The Rule of Zero revisited: The Rule of All or Nothing

by Arne Mertz

From the article:

In 2012, Martinho Fernandes coined the Rule of Zero in a blog post. In 2014, Scott Meyers wrote a blog post about a concern with that rule and proposed a Rule of Five Defaults.

Back then, I had written a small comment on Scott’s post that deserves some further elaboration. In this post I am going to wrap up my thoughts about the two posts and propose a “Rule of All or Nothing”...

the asynchronous library - Christophe Henry @ Meeting C++ 2014

A new video from Meeting C++ 2014:

the asynchronous library

by Christophe Henry

From the talk description:

An infrastructure library on which Boost Meta State Machine can build. This will be provided by the Asynchronous library: Active Objects, proxies, threadpools, parallelization algorithms, work-stealing, distributed programming...

2015-02 mid-meeting mailing available

The 2015-02 mailing of new standards papers is now available.

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
N4340 Remove Deprecated Use of the register Keyword Alisdair Meredith 2014-11-26 2015-02   Evolution  
N4341 C++ Standard Library Active Issues List (Revision R92) Alisdair Meredith   missing   Library  
N4342 C++ Standard Library Defect Report List (Revision R92) Alisdair Meredith   missing   Library  
N4343 C++ Standard Library Closed Issues List (Revision R92) Alisdair Meredith   missing   Library  
N4344 Suggested Design for Customization Points Eric Niebler   missing   Library  
N4345 Ranges for the Standard Library, Revision 2 Eric Niebler   missing   Library  
N4346 Multidimensional bounds, index and array_view, revision 5 Lukasz Mendakiewicz 2015-01-05 2015-02 N4177 Library  
N4347 Responses to National Body Comments, PDTS 19568, Library Fundamentals Barry Hedquist   missing      
N4348 Making std::function thread-safe Geoffrey Romer 2015-02-02 2015-02 N4159 Library  
N4349 Minutes of WG21 Telecon Jonathan Wakely 2014-12-05 2015-02      
N4350 Agenda and Meeting Notice for WG21 Concepts Meeting Notice (revision 1) Herb Sutter 2015-01-15 2015-02 N4339    
N4351 Responses to National Body Comments, PDTS 19570, C++ Extensions for Parallelism Barry Hedquist 2014-12-23 2015-02      
N4352 Parallelism TS Jared Hoberock 2015-01-08 2015-02 N4310    
N4353 Parallelism TS - Editor's Report Jared Hoberock 2015-01-08 2015-02      
N4354 Parallelism TS - DTS Ballot Document Jared Hoberock 2015-01-08 2015-02      
N4355 Shared Multidimensional Arrays with Polymorphic Layout Carter Edwards 2015-02-04 2015-02   Library  
N4356 Relaxed Array Type Declarator Carter Edwards 2015-02-04 2015-02   Evolution  
N4357 Introduce the [[noexit]] attribute for main as a hint to eliminate destructor calls for objects with static storage duration Jens Maurer 2015-01-19 2015-02 N4226 Evolution  
N4358 Unary Folds and Empty Parameter Packs Thibaut Le Jehan 2015-01-20 2015-02   Evolution  
N4359 A Proposal to Add vector release method just like unique_ptr release method to the Standard Library Jerry Liang 2015-01-09 2015-02   Library  
N4360 Delayed Evaluation Parameters Douglas Boffey 2015-01-22 2015-02   Evolution  
N4361 Concepts Lite TS Andrew Sutton 2015-01-27 2015-02 N4333    
N4362 WG21 2015-01 Skillman Minutes John Spicer 2015-01-27 2015-02      
N4363 Library Fundamentals v1 DTS Jeffrey Yasskin   missing      
N4364 Editor's Report for the Library Fundamentals v1 DTS Jeffrey Yasskin   missing      
N4365 Responses to National Body Comments, ISO/IEC PDTS 19568, C++ Extensions for Library Fundamentals Barry Hedquist 2015-01-29 2015-02      
N4366 LWG 2228: Missing SFINAE rule in unique_ptr templated assignment Howard Hinnant 2015-01-11 2015-02   Library  
N4367 Comparison in C++ Lawrence Crowl 2015-02-08 2015-02   Evolution  
N4368 Introducing alias size_type for type size_t in class std::bitset Vladimir Grigoriev 2015-02-03 2015-02   Library evolution  
N4369 Default argument for second parameter of std::advance Vladimir Grigoriev 2015-01-12 2015-02   Library evolution  
N4370 Networking Library Proposal (Revision 4) Christopher Kohlhoff 2015-02-06 2015-02 N4332 Library  
N4371 Minimal incomplete type support for standard containers, revision 2 Zhihao Yuan 2015-02-04 2015-02 N4056 Library  
N4372 A Proposal to Add a Const-Propagating Wrapper to the Standard Library Jonathan Coe 2015-02-06 2015-02 N4209 Library  
N4373 Atomic View Carter Edwards, Hans Boehm 2015-01-26 2015-02 N4142 Library  
N4374 Linux-Kernel Memory Mode Paul E. McKenney 2015-02-06 2015-02 N4322 Concurrency  
N4375 Out-of-Thin-Air Execution is Vacuous Paul E. McKenney 2015-02-06 2015-02 N4323 Concurrency  
N4376 Use Cases for Thread-Local Storage Paul E. McKenney 2015-02-06 2015-02 N4324 Concurrency  
N4377 C++ Extensions for Concepts PDTS Andrew Sutton 2015-02-09 2015-02      
N4378 Language Support for Contract Assertions John Lakos, Nathan Myers, Alexei Zakharov, Alexander Beels 2015-02-08 2015-02   Evolution  
N4379 FAQ about N4378, Language Support for Contract Assertions John Lakos, Nathan Myers 2015-02-08 2015-02   Evolution  
N4380 Constant View: A proposal for a std::as_const helper function template ADAM David Alan Martin, Alisdair Meredith 2015-02-05 2015-02   Library  

CppCon 2014 How HHVM Uses Modern C++ for Fun and Profit (Literally)--Drew Paroski

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

How HHVM Uses Modern C++ for Fun and Profit (Literally)

by Drew Paroski

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

HHVM is a just-in-time compiler for PHP used by Facebook to serve billions of requests each day. This talk will give a quick overview of HHVM's history and architecture, followed by a deep dive into what made C++ the language of choice for writing HHVM.

C++ hits a sweet spot between performance and control on one end, and safety, maintainability, and convenience on the other.

The topics we’ll cover will include:
how to call into generated machine code from C++;
taking advantage of C++'s power to control "unsafe" details with memory including how memory is allocated, field size and layout, unions, reinterpret_casts, bit-stealing;
integrating generated machine code with C++ exception handling and C++ profiling tools;
leveraging templates and using the X Macro technique to improve performance and maintainability;
and taking advantage of new C++11 features like unrestricted unions and move constructors.
Finally, we'll go over some obstacles we encountered such as generating machine code that calls C++ virtual methods, and how C++'s superb flexibility allowed us to work around these obstacles.

Call for Papers: C++ track at NDC Oslo 2015, June 17-19

ndc-2015.pngThere was a lot of interest for the very strong C++ track that we hosted at the NDC conference in Oslo last summer. Here is a brief summary of the event, including links to the videos we recorded.

We are repeating the success this year, June 17-19. A few big C++ names has already been signed up, but there is still available slots in the agenda. If you would like to be part of the C++ track this year, please submit your proposal soon.

Call For Papers for NDC Oslo 2015

The CFP closes February 15.

 

Desired compile-time failures--Andrzej KrzemieĊ„ski

Sometimes, an error is what we want:

Desired compile-time failures

by Andrzej Krzemieński

From the article:

However, even though [not introducing breaking changes] works in most of the cases, I believe that this criterion of a “safe addition” is not technically correct, as it fails to take into account an important fact: failure to compile certain programs is a useful, important feature, and if these programs suddenly start to compile, it can cause harm. In this post we will go through the cases where compile-time failure is considered a useful feature...

GCC5 and the C++11 ABI--rhjason

A new article of interest for library developers:

GCC5 and the C++11 ABI

by rhjason

From the article:

The GNU C++ team works hard to avoid breaking ABI compatibility between releases, including between different -std= modes. But some new complexity requirements in the C++11 standard require ABI changes to several standard library classes to satisfy, most notably to std::basic_string and std::list. And since std::basic_string is used widely, much of the standard library is affected...

Overload 125 is now available

ACCU's Overload journal of February 2015 is out. It contains C++ related articles.

Overload 125

From the journal:

Making a Tool of Deception: Is it possible to use modern C++ to make mocking easy? Björn Fahller introduces Trompeloeil, a header-only mocking framework for C++14.

Modern C++ Testing: Various C++ testing framework exist. Phil Nash compares CATCH with the competition.

I Like Whitespaces: Bob Schmidt shares why he thinks whitespaces matters.