Skip to content

Commit

Permalink
Allow uitsl namespace redefinition in macro
Browse files Browse the repository at this point in the history
  • Loading branch information
mmore500 committed Oct 14, 2022
1 parent 7e3d2be commit 73369a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/uitsl/debug/uitsl_always_assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "../meta/is_streamable.hpp"
#include "../meta/fwd_or_cast.hpp"
#include "../meta/UITSL_NAMESPACE.hpp"
#include "../utility/UITSL_STRINGIFY.hpp"
#include "../utility/SetSeparator.hpp"

Expand All @@ -15,12 +16,13 @@
#define uitsl_always_assert(expr, ...) \
do { \
if(!(expr)) { \
namespace uitsl_ns = UITSL_NAMESPACE(); \
std::cout << '\n'; \
std::cout << '\n'; \
std::cout << "ASSERTION FAILED: "; \
std::cout << '\n'; \
std::cout << UITSL_STRINGIFY(expr) << " was "; \
std::cout << uitsl::fwd_or_cast<uitsl::is_streamable, bool>(expr); \
std::cout << uitsl_ns::fwd_or_cast<uitsl_ns::is_streamable, bool>(expr); \
std::cout << '\n'; \
std::cout << '\n'; \
std::cout << "FILE: " << __FILE__ << '\n'; \
Expand All @@ -29,7 +31,7 @@ do { \
std::cout << '\n'; \
std::cout << "MESSAGE:\n"; \
std::cout << UITSL_STRINGIFY(__VA_ARGS__) << '\n'; \
std::cout << uitsl::SetSeparator(" << ") __VA_OPT__(<<) __VA_ARGS__; \
std::cout << uitsl_ns::SetSeparator(" << ") __VA_OPT__(<<) __VA_ARGS__; \
std::cout << '\n'; \
std::abort(); \
} \
Expand Down
14 changes: 14 additions & 0 deletions include/uitsl/meta/UITSL_NAMESPACE.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once
#ifndef UITSL_META_UITSL_NAMESPACE_HPP_INCLUDE
#define UITSL_META_UITSL_NAMESPACE_HPP_INCLUDE

#ifndef UITSL_NAMESPACE
#define UITSL_NAMESPACE() uitsl
#endif // #ifndef UITSL_NAMESPACE






#endif // #ifndef UITSL_META_UITSL_NAMESPACE_HPP_INCLUDE

0 comments on commit 73369a1

Please sign in to comment.