Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-08-18 11:35:58 +0200
committerMartin Hořeňovský2020-08-18 21:02:23 +0200
commite7eb74981513364e6543aeec30446fda4c9a3de9 (patch)
treee8580a3a0963a99e90f374e831152d5dc10c98e0 /src/catch2/internal
parentc1bb699d45fd3e6eb349525110983b61d4a936a2 (diff)
downloadcatch3-e7eb74981513364e6543aeec30446fda4c9a3de9.tar.gz
Split the NonCopyable helper out of catch_common.hpp
Diffstat (limited to 'src/catch2/internal')
-rw-r--r--src/catch2/internal/catch_clara.hpp12
-rw-r--r--src/catch2/internal/catch_common.hpp9
-rw-r--r--src/catch2/internal/catch_context.cpp4
-rw-r--r--src/catch2/internal/catch_noncopyable.hpp21
-rw-r--r--src/catch2/internal/catch_section.hpp3
-rw-r--r--src/catch2/internal/catch_stream.hpp4
-rw-r--r--src/catch2/internal/catch_test_registry.hpp3
-rw-r--r--src/catch2/internal/catch_xmlwriter.hpp7
8 files changed, 39 insertions, 24 deletions
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 <catch2/internal/catch_noncopyable.hpp>
+
#include <cassert>
#include <cctype>
#include <memory>
@@ -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 <catch2/internal/catch_context.hpp>
-#include <catch2/internal/catch_common.hpp>
+#include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/internal/catch_random_number_generator.hpp>
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 <catch2/internal/catch_compiler_capabilities.hpp>
+#include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/catch_section_info.hpp>
#include <catch2/catch_timer.hpp>
#include <catch2/catch_totals.hpp>
@@ -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 <catch2/internal/catch_common.hpp>
+#include <catch2/internal/catch_noncopyable.hpp>
#include <iosfwd>
#include <cstddef>
@@ -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 <catch2/internal/catch_common.hpp>
+#include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/interfaces/catch_interfaces_testcase.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_stringref.hpp>
@@ -52,7 +53,7 @@ struct NameAndTags {
StringRef tags;
};
-struct AutoReg : NonCopyable {
+struct AutoReg : Detail::NonCopyable {
AutoReg( Detail::unique_ptr<ITestInvoker> 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 <catch2/internal/catch_stream.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
+// 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 <catch2/internal/catch_common.hpp>
+
+
#include <vector>
namespace Catch {