mirror of
https://github.com/Z3Prover/z3
synced 2025-05-05 23:05:46 +00:00
Better search stack printing
This commit is contained in:
parent
59f2603a3a
commit
00fa4b3320
4 changed files with 106 additions and 14 deletions
|
@ -18,29 +18,51 @@ Author:
|
|||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
#include "util/ref.h"
|
||||
#include "util/util.h"
|
||||
|
||||
template <typename T>
|
||||
struct show_deref_t {
|
||||
T const* ptr;
|
||||
T const* ptr;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
std::ostream& operator<<(std::ostream& os, show_deref_t<T> s) {
|
||||
if (s.ptr)
|
||||
return os << *s.ptr;
|
||||
else
|
||||
return os << "<null>";
|
||||
if (s.ptr)
|
||||
return os << *s.ptr;
|
||||
else
|
||||
return os << "<null>";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
show_deref_t<T> show_deref(T* ptr) {
|
||||
return show_deref_t<T>{ptr};
|
||||
return show_deref_t<T>{ptr};
|
||||
}
|
||||
|
||||
template <typename Ptr, typename T = typename std::remove_pointer<decltype(std::declval<Ptr>().get())>::type>
|
||||
show_deref_t<T> show_deref(Ptr const& ptr) {
|
||||
return show_deref_t<T>{ptr.get()};
|
||||
return show_deref_t<T>{ptr.get()};
|
||||
}
|
||||
|
||||
/// Fill with spaces to the right:
|
||||
/// out << rpad(8, "hello")
|
||||
/// writes "hello ".
|
||||
template <typename T>
|
||||
struct rpad {
|
||||
unsigned width;
|
||||
T const& obj;
|
||||
rpad(unsigned width, T const& obj): width(width), obj(obj) {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
std::ostream& operator<<(std::ostream& out, rpad<T> const& pad) {
|
||||
std::stringstream tmp;
|
||||
tmp << pad.obj;
|
||||
auto s = tmp.str();
|
||||
out << s;
|
||||
if (s.length() < pad.width)
|
||||
out << std::string(pad.width - s.length(), ' ');
|
||||
return out;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue