From 9f26495ced872d772f063394e7e8f5a75f1921df Mon Sep 17 00:00:00 2001 From: Frank Park Date: Sun, 2 Apr 2017 11:06:12 -0400 Subject: [PATCH] Reordered template arguments --- include/sqlpp11/connection_pool.h | 29 +++++++++++++---------------- include/sqlpp11/pool_connection.h | 4 ++-- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/include/sqlpp11/connection_pool.h b/include/sqlpp11/connection_pool.h index 5d5181da..67ce9ea9 100644 --- a/include/sqlpp11/connection_pool.h +++ b/include/sqlpp11/connection_pool.h @@ -104,11 +104,11 @@ namespace sqlpp } template ::value, Connection_config::connection>::type, - typename Reconnect_policy = reconnect_policy::auto_reconnect> + typename Reconnect_policy = reconnect_policy::auto_reconnect, + typename Connection = typename std::enable_if::value, Connection_config::connection>::type> class connection_pool { - friend pool_connection; + friend pool_connection; private: std::mutex connection_pool_mutex; @@ -145,9 +145,8 @@ namespace sqlpp } public: - connection_pool(const std::shared_ptr& config, size_t pool_size, - Reconnect_policy reconnect_policy = sqlpp::reconnect_policy::auto_reconnect()) - : config(config), maximum_pool_size(pool_size), reconnect_policy(reconnect_policy) {} + connection_pool(const std::shared_ptr& config, size_t pool_size) + : config(config), maximum_pool_size(pool_size), reconnect_policy(Reconnect_policy()) {} ~connection_pool() = default; connection_pool(const connection_pool&) = delete; connection_pool(connection_pool&& other) @@ -156,19 +155,19 @@ namespace sqlpp connection_pool& operator=(const connection_pool&) = delete; connection_pool& operator=(connection_pool&&) = delete; - pool_connection get_connection() + pool_connection get_connection() { std::lock_guard lock(connection_pool_mutex); if (!free_connections.empty()) { auto connection = std::move(free_connections.top()); free_connections.pop(); - return pool_connection(connection, this); + return pool_connection(connection, this); } try { - return pool_connection(std::move(std::make_unique(config)), this); + return pool_connection(std::move(std::make_unique(config)), this); } catch (const sqlpp::exception& e) { @@ -180,15 +179,13 @@ namespace sqlpp }; template::value, Connection_config::connection>::type, - typename Reconnect_policy = reconnect_policy::auto_reconnect> - connection_pool make_connection_pool( + typename Reconnect_policy = reconnect_policy::auto_reconnect, + typename Connection = typename std::enable_if::value,Connection_config::connection>::type> + connection_pool make_connection_pool( const std::shared_ptr& config, - size_t max_pool_size, - Reconnect_policy reconnect_policy = reconnect_policy::auto_reconnect() - ) + size_t max_pool_size) { - return connection_pool(config, max_pool_size, reconnect_policy); + return connection_pool(config, max_pool_size); } } diff --git a/include/sqlpp11/pool_connection.h b/include/sqlpp11/pool_connection.h index 426e0c83..12ba5bce 100644 --- a/include/sqlpp11/pool_connection.h +++ b/include/sqlpp11/pool_connection.h @@ -31,8 +31,8 @@ namespace sqlpp { - template > + template > struct pool_connection { private: