Skip to content
This repository was archived by the owner on May 3, 2026. It is now read-only.

Commit 58841df

Browse files
committed
throw error if result_impl.hpp is included
1 parent ee47b0f commit 58841df

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

include/common/result.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22

3+
#define I_WANT_RESULT_IMPL
34
#include "common/result_impl.hpp"
5+
#undef I_WANT_RESULT_IMPL
46

57
#include <functional>
68

include/common/result_impl.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
#include <stacktrace>
77
#include <variant> // IWYU pragma: keep (std::get is used, not sure why clangd says this header isn't needed)
88

9+
// No file other than result.hpp should include result_impl.hpp.
10+
// The include level macro is used to prevent the error being thrown when viewing this file
11+
#if !defined(I_WANT_RESULT_IMPL) && __INCLUDE_LEVEL__ > 0
12+
#error Don't include "result_impl.hpp", include "result.hpp" instead
13+
#endif
14+
915
namespace zest {
1016

1117
/**

0 commit comments

Comments
 (0)