Put fmt library into contrib and use it

Changes all uses of boost::format to use the "xxx"_format syntax of the
fmt library. Starting from C++14 this will parse the format strings at
compile time making sure the format string and the arguments fit
together.

This also changes the CMake config so that you can set the C++ version
to compile with by using something like -DCMAKE_CXX_STANDARD=14 . C++11
is still the default.

On travis bionic builds are now using C++14.
This commit is contained in:
Jochen Topf
2019-11-24 14:52:21 +01:00
parent 8adf6ce916
commit 4eea0a0274
41 changed files with 10432 additions and 267 deletions

View File

@ -13,8 +13,8 @@ static std::shared_ptr<db_target_descr_t> setup_table(std::string const &cols)
{
auto conn = db.connect();
conn.exec("DROP TABLE IF EXISTS test_copy_mgr");
conn.exec(boost::format("CREATE TABLE test_copy_mgr (id int8%1%%2%)") %
(cols.empty() ? "" : ",") % cols);
conn.exec("CREATE TABLE test_copy_mgr (id int8{}{})"_format(
cols.empty() ? "" : ",", cols));
auto table = std::make_shared<db_target_descr_t>();
table->name = "test_copy_mgr";
@ -182,9 +182,9 @@ TEST_CASE("db_copy_mgr_t")
auto c = db.connect();
auto sql = boost::format("SELECT h->'%1%' from test_copy_mgr");
for (auto const &v : values) {
auto res = c.require_scalar<std::string>((sql % v.first).str());
auto const res = c.require_scalar<std::string>(
"SELECT h->'{}' FROM test_copy_mgr"_format(v.first));
CHECK(res == v.second);
}
}