From 49bd8ac88064d98403f189c7bdb56160ab80c90b Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 16 Jan 2014 18:29:30 -0500 Subject: [PATCH] Tidy up for C++11, and fixes: * Remove shared_ptr legacy support * Add make_unique support for pre-C++14 environments * Fix comparison bug in sqdb * Use std::shared_ptr in a few places --- Builds/VisualStudio2012/beast.vcxproj | 1 - Builds/VisualStudio2012/beast.vcxproj.filters | 3 -- beast/STL.h | 25 -------------- beast/insight/CounterImpl.h | 1 - beast/insight/GaugeImpl.h | 3 ++ beast/insight/Hook.h | 2 +- beast/insight/Meter.h | 2 +- beast/make_unique.h | 6 ++++ beast/stl/STL.cpp | 22 ------------- beast/stl/shared_ptr.h | 33 ------------------- modules/beast_core/beast_core.h | 1 - modules/beast_sqdb/source/session.cpp | 3 +- 12 files changed, 13 insertions(+), 89 deletions(-) delete mode 100644 beast/STL.h delete mode 100644 beast/stl/STL.cpp delete mode 100644 beast/stl/shared_ptr.h diff --git a/Builds/VisualStudio2012/beast.vcxproj b/Builds/VisualStudio2012/beast.vcxproj index 27e6fbd84..8914c8f9a 100644 --- a/Builds/VisualStudio2012/beast.vcxproj +++ b/Builds/VisualStudio2012/beast.vcxproj @@ -162,7 +162,6 @@ - diff --git a/Builds/VisualStudio2012/beast.vcxproj.filters b/Builds/VisualStudio2012/beast.vcxproj.filters index 9caf855ab..0f09ebf75 100644 --- a/Builds/VisualStudio2012/beast.vcxproj.filters +++ b/Builds/VisualStudio2012/beast.vcxproj.filters @@ -1158,9 +1158,6 @@ beast\smart_ptr - - beast - beast diff --git a/beast/STL.h b/beast/STL.h deleted file mode 100644 index 730eb22eb..000000000 --- a/beast/STL.h +++ /dev/null @@ -1,25 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_STL_H_INCLUDED -#define BEAST_STL_H_INCLUDED - -#include "stl/shared_ptr.h" - -#endif diff --git a/beast/insight/CounterImpl.h b/beast/insight/CounterImpl.h index 963151490..f6c0b6e0d 100644 --- a/beast/insight/CounterImpl.h +++ b/beast/insight/CounterImpl.h @@ -20,7 +20,6 @@ #ifndef BEAST_INSIGHT_COUNTERIMPL_H_INCLUDED #define BEAST_INSIGHT_COUNTERIMPL_H_INCLUDED -#include #include namespace beast { diff --git a/beast/insight/GaugeImpl.h b/beast/insight/GaugeImpl.h index 50ff9b586..e816e6ce7 100644 --- a/beast/insight/GaugeImpl.h +++ b/beast/insight/GaugeImpl.h @@ -20,6 +20,9 @@ #ifndef BEAST_INSIGHT_GAUGEIMPL_H_INCLUDED #define BEAST_INSIGHT_GAUGEIMPL_H_INCLUDED +#include +#include + namespace beast { namespace insight { diff --git a/beast/insight/Hook.h b/beast/insight/Hook.h index 3b45992e3..a529c0e1b 100644 --- a/beast/insight/Hook.h +++ b/beast/insight/Hook.h @@ -22,7 +22,7 @@ #include "HookImpl.h" -#include "../stl/shared_ptr.h" +#include namespace beast { namespace insight { diff --git a/beast/insight/Meter.h b/beast/insight/Meter.h index bc7c72f9b..3471fb31f 100644 --- a/beast/insight/Meter.h +++ b/beast/insight/Meter.h @@ -22,7 +22,7 @@ #include "MeterImpl.h" -#include "../stl/shared_ptr.h" +#include namespace beast { namespace insight { diff --git a/beast/make_unique.h b/beast/make_unique.h index c48e7e0d3..e26402ae2 100644 --- a/beast/make_unique.h +++ b/beast/make_unique.h @@ -24,6 +24,12 @@ namespace std { +#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES +# ifdef _MSC_VER +# define BOOST_NO_CXX11_VARIADIC_TEMPLATES +# endif +#endif + #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES template diff --git a/beast/stl/STL.cpp b/beast/stl/STL.cpp deleted file mode 100644 index 24ed420bf..000000000 --- a/beast/stl/STL.cpp +++ /dev/null @@ -1,22 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include "BeastConfig.h" - -#include "shared_ptr.h" diff --git a/beast/stl/shared_ptr.h b/beast/stl/shared_ptr.h deleted file mode 100644 index 3d2875b4d..000000000 --- a/beast/stl/shared_ptr.h +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_STL_SHARED_PTR_H_INCLUDED -#define BEAST_STL_SHARED_PTR_H_INCLUDED - -#include - -namespace beast { - -using boost::shared_ptr; -using boost::make_shared; -using boost::enable_shared_from_this; - -} - -#endif diff --git a/modules/beast_core/beast_core.h b/modules/beast_core/beast_core.h index c3526cf91..faec9deb1 100644 --- a/modules/beast_core/beast_core.h +++ b/modules/beast_core/beast_core.h @@ -61,7 +61,6 @@ #include "../../beast/Threads.h" #include "../../beast/Utility.h" #include "../../beast/Chrono.h" -#include "../../beast/STL.h" #include "system/StandardIncludes.h" diff --git a/modules/beast_sqdb/source/session.cpp b/modules/beast_sqdb/source/session.cpp index 6e18c66eb..ff8a71cc8 100644 --- a/modules/beast_sqdb/source/session.cpp +++ b/modules/beast_sqdb/source/session.cpp @@ -139,7 +139,8 @@ Error session::open(String fileName, std::string options) std::stringstream ssconn(options); - while (!err && !ssconn.eof() && ssconn.str().find('=') >= 0) + while (!err && !ssconn.eof() && + ssconn.str().find('=') != std::string::npos) { std::string key, val; std::getline(ssconn, key, '=');