diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de7010be..932ff876 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,6 +38,7 @@ set(INTERNAL_HEADERS ${SOURCES_DIR}/matchers/internal/catch_matchers_impl.hpp ${SOURCES_DIR}/internal/catch_console_width.hpp ${SOURCES_DIR}/internal/catch_container_nonmembers.hpp + ${SOURCES_DIR}/internal/catch_noncopyable.hpp ${SOURCES_DIR}/catch_approx.hpp ${SOURCES_DIR}/internal/catch_assertion_handler.hpp ${SOURCES_DIR}/catch_assertion_info.hpp diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index a6448229..a5bdd50b 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include diff --git a/src/catch2/catch_registry_hub.cpp b/src/catch2/catch_registry_hub.cpp index af4db897..c25b1cec 100644 --- a/src/catch2/catch_registry_hub.cpp +++ b/src/catch2/catch_registry_hub.cpp @@ -18,13 +18,15 @@ #include #include #include +#include namespace Catch { namespace { - class RegistryHub : public IRegistryHub, public IMutableRegistryHub, - private NonCopyable { + class RegistryHub : public IRegistryHub, + public IMutableRegistryHub, + private Detail::NonCopyable { public: // IRegistryHub RegistryHub() = default; diff --git a/src/catch2/catch_session.hpp b/src/catch2/catch_session.hpp index 6c560c63..3c7f3c22 100644 --- a/src/catch2/catch_session.hpp +++ b/src/catch2/catch_session.hpp @@ -9,12 +9,14 @@ #define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED #include +#include #include #include +#include namespace Catch { - class Session : NonCopyable { + class Session : Detail::NonCopyable { public: Session(); diff --git a/src/catch2/catch_test_case_info.hpp b/src/catch2/catch_test_case_info.hpp index 991cca61..1d2c1b12 100644 --- a/src/catch2/catch_test_case_info.hpp +++ b/src/catch2/catch_test_case_info.hpp @@ -9,6 +9,7 @@ #define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED #include +#include #include #include #include @@ -44,7 +45,7 @@ namespace Catch { }; - struct TestCaseInfo : NonCopyable { + struct TestCaseInfo : Detail::NonCopyable { TestCaseInfo(std::string const& _className, NameAndTags const& _tags, diff --git a/src/catch2/interfaces/catch_interfaces_config.hpp b/src/catch2/interfaces/catch_interfaces_config.hpp index a2cb88a8..f0f19167 100644 --- a/src/catch2/interfaces/catch_interfaces_config.hpp +++ b/src/catch2/interfaces/catch_interfaces_config.hpp @@ -8,7 +8,7 @@ #ifndef TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED #define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED -#include +#include #include #include @@ -53,7 +53,7 @@ namespace Catch { class TestSpec; - struct IConfig : NonCopyable { + struct IConfig : Detail::NonCopyable { virtual ~IConfig(); diff --git a/src/catch2/interfaces/catch_interfaces_registry_hub.hpp b/src/catch2/interfaces/catch_interfaces_registry_hub.hpp index 3e99d215..14fa06a5 100644 --- a/src/catch2/interfaces/catch_interfaces_registry_hub.hpp +++ b/src/catch2/interfaces/catch_interfaces_registry_hub.hpp @@ -8,7 +8,6 @@ #ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED #define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED -#include #include #include @@ -25,6 +24,7 @@ namespace Catch { struct ITagAliasRegistry; struct ITestInvoker; struct IMutableEnumValuesRegistry; + struct SourceLineInfo; class StartupExceptionRegistry; diff --git a/src/catch2/internal/catch_clara.hpp b/src/catch2/internal/catch_clara.hpp index f85c8e14..d4aca873 100644 --- a/src/catch2/internal/catch_clara.hpp +++ b/src/catch2/internal/catch_clara.hpp @@ -30,6 +30,8 @@ # endif #endif +#include + #include #include #include @@ -286,15 +288,7 @@ namespace Catch { } #endif // CLARA_CONFIG_OPTIONAL_TYPE - struct NonCopyable { - NonCopyable() = default; - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable&& ) = delete; - NonCopyable& operator=( NonCopyable const& ) = delete; - NonCopyable& operator=( NonCopyable&& ) = delete; - }; - - struct BoundRef : NonCopyable { + struct BoundRef : Catch::Detail::NonCopyable { virtual ~BoundRef() = default; virtual auto isContainer() const -> bool { return false; } virtual auto isFlag() const -> bool { return false; } diff --git a/src/catch2/internal/catch_common.hpp b/src/catch2/internal/catch_common.hpp index 45a1eca5..1229b9e2 100644 --- a/src/catch2/internal/catch_common.hpp +++ b/src/catch2/internal/catch_common.hpp @@ -32,15 +32,6 @@ namespace Catch { No }; }; - class NonCopyable { - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable && ) = delete; - NonCopyable& operator = ( NonCopyable const& ) = delete; - NonCopyable& operator = ( NonCopyable && ) = delete; - protected: - NonCopyable() noexcept = default; - }; - struct SourceLineInfo { SourceLineInfo() = delete; diff --git a/src/catch2/internal/catch_context.cpp b/src/catch2/internal/catch_context.cpp index ed7b0150..821380da 100644 --- a/src/catch2/internal/catch_context.cpp +++ b/src/catch2/internal/catch_context.cpp @@ -6,12 +6,12 @@ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #include -#include +#include #include namespace Catch { - class Context : public IMutableContext, NonCopyable { + class Context : public IMutableContext, private Detail::NonCopyable { public: // IContext IResultCapture* getResultCapture() override { diff --git a/src/catch2/internal/catch_noncopyable.hpp b/src/catch2/internal/catch_noncopyable.hpp new file mode 100644 index 00000000..217bac4d --- /dev/null +++ b/src/catch2/internal/catch_noncopyable.hpp @@ -0,0 +1,21 @@ +#ifndef CATCH_NONCOPYABLE_HPP_INCLUDED +#define CATCH_NONCOPYABLE_HPP_INCLUDED + +namespace Catch { + namespace Detail { + + //! Deriving classes become noncopyable and nonmovable + class NonCopyable { + NonCopyable( NonCopyable const& ) = delete; + NonCopyable( NonCopyable&& ) = delete; + NonCopyable& operator=( NonCopyable const& ) = delete; + NonCopyable& operator=( NonCopyable&& ) = delete; + + protected: + NonCopyable() noexcept = default; + }; + + } // namespace Detail +} // namespace Catch + +#endif // CATCH_NONCOPYABLE_HPP_INCLUDED diff --git a/src/catch2/internal/catch_section.hpp b/src/catch2/internal/catch_section.hpp index bdaf54af..fa0a64ae 100644 --- a/src/catch2/internal/catch_section.hpp +++ b/src/catch2/internal/catch_section.hpp @@ -9,6 +9,7 @@ #define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED #include +#include #include #include #include @@ -17,7 +18,7 @@ namespace Catch { - class Section : NonCopyable { + class Section : Detail::NonCopyable { public: Section( SectionInfo&& info ); ~Section(); diff --git a/src/catch2/internal/catch_stream.hpp b/src/catch2/internal/catch_stream.hpp index 51d32e62..98788fea 100644 --- a/src/catch2/internal/catch_stream.hpp +++ b/src/catch2/internal/catch_stream.hpp @@ -9,7 +9,7 @@ #ifndef TWOBLUECUBES_CATCH_STREAM_H_INCLUDED #define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED -#include +#include #include #include @@ -30,7 +30,7 @@ namespace Catch { auto makeStream( StringRef const &filename ) -> IStream const*; - class ReusableStringStream : NonCopyable { + class ReusableStringStream : Detail::NonCopyable { std::size_t m_index; std::ostream* m_oss; public: diff --git a/src/catch2/internal/catch_test_registry.hpp b/src/catch2/internal/catch_test_registry.hpp index fd6d7d21..f9dc6255 100644 --- a/src/catch2/internal/catch_test_registry.hpp +++ b/src/catch2/internal/catch_test_registry.hpp @@ -9,6 +9,7 @@ #define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED #include +#include #include #include #include @@ -52,7 +53,7 @@ struct NameAndTags { StringRef tags; }; -struct AutoReg : NonCopyable { +struct AutoReg : Detail::NonCopyable { AutoReg( Detail::unique_ptr invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept; }; diff --git a/src/catch2/internal/catch_xmlwriter.hpp b/src/catch2/internal/catch_xmlwriter.hpp index 3102dc6a..56de2e43 100644 --- a/src/catch2/internal/catch_xmlwriter.hpp +++ b/src/catch2/internal/catch_xmlwriter.hpp @@ -11,6 +11,13 @@ #include #include +// FixMe: Without this include (and something inside it), MSVC goes crazy +// and reports that calls to XmlEncode's op << are ambiguous between +// the declaration and definition. +// It also has to be in the header. +#include + + #include namespace Catch {