From fc0b74f986ca520d81e2dda6f00cd3941e956d55 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Fri, 17 Apr 2020 14:05:51 -0700 Subject: [PATCH] Refactor memory resource includes --- include/boost/json/config.hpp | 4 -- include/boost/json/detail/config.hpp | 2 - .../boost/json/detail/counted_resource.hpp | 3 +- include/boost/json/memory_resource.hpp | 37 +++++++++++++++++++ include/boost/json/storage_ptr.hpp | 1 + test/Jamfile | 1 + test/memory_resource.cpp | 11 ++++++ 7 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 include/boost/json/memory_resource.hpp create mode 100644 test/memory_resource.cpp diff --git a/include/boost/json/config.hpp b/include/boost/json/config.hpp index 71bcf42e..a3d5ae57 100644 --- a/include/boost/json/config.hpp +++ b/include/boost/json/config.hpp @@ -20,13 +20,9 @@ namespace json { /// The type of string view used by the library. using string_view = boost::string_view; -/// The type of memory_resource used by the library. -using memory_resource = boost::container::pmr::memory_resource; - #else using string_view = std::string_view; -using memory_resource = std::pmr::memory_resource; #endif diff --git a/include/boost/json/detail/config.hpp b/include/boost/json/detail/config.hpp index da0e4f00..cb6f2aab 100644 --- a/include/boost/json/detail/config.hpp +++ b/include/boost/json/detail/config.hpp @@ -13,12 +13,10 @@ #ifndef BOOST_JSON_STANDALONE # include # include -# include # include # include #else # include -# include # include #endif #include diff --git a/include/boost/json/detail/counted_resource.hpp b/include/boost/json/detail/counted_resource.hpp index 69d2aa92..3d6427ac 100644 --- a/include/boost/json/detail/counted_resource.hpp +++ b/include/boost/json/detail/counted_resource.hpp @@ -10,8 +10,9 @@ #ifndef BOOST_JSON_DETAIL_COUNTED_RESOURCE_HPP #define BOOST_JSON_DETAIL_COUNTED_RESOURCE_HPP -#include +#include #include +#include namespace boost { namespace json { diff --git a/include/boost/json/memory_resource.hpp b/include/boost/json/memory_resource.hpp new file mode 100644 index 00000000..a779c890 --- /dev/null +++ b/include/boost/json/memory_resource.hpp @@ -0,0 +1,37 @@ +// +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/json +// + +#ifndef BOOST_JSON_MEMORY_RESOURCE_HPP +#define BOOST_JSON_MEMORY_RESOURCE_HPP + +#include +#ifndef BOOST_JSON_STANDALONE +# include +#else +# include +#endif + +namespace boost { +namespace json { + +#ifndef BOOST_JSON_STANDALONE + +/// The type of memory_resource used by the library. +using memory_resource = boost::container::pmr::memory_resource; + +#else + +using memory_resource = std::pmr::memory_resource; + +#endif + +} // json +} // boost + +#endif diff --git a/include/boost/json/storage_ptr.hpp b/include/boost/json/storage_ptr.hpp index f006ba32..3e6f635f 100644 --- a/include/boost/json/storage_ptr.hpp +++ b/include/boost/json/storage_ptr.hpp @@ -11,6 +11,7 @@ #define BOOST_JSON_STORAGE_PTR_HPP #include +#include #include #include #include diff --git a/test/Jamfile b/test/Jamfile index dcae874e..788121e1 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -31,6 +31,7 @@ local SOURCES = except.cpp json.cpp kind.cpp + memory_resource.cpp monotonic_resource.cpp number_cast.cpp object.cpp diff --git a/test/memory_resource.cpp b/test/memory_resource.cpp new file mode 100644 index 00000000..a8c7e223 --- /dev/null +++ b/test/memory_resource.cpp @@ -0,0 +1,11 @@ +// +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/json +// + +// Test that header file is self-contained. +#include