fix(debug): print type in lean_assert, print bool correctly

- use typeinfo to print out a type of value when an assertion fails.
   need to use "c++filt --types" to demangle names for non-basic types.
 - use std::boolalpha and std::noboolalpha to control the printed values
   for "true" and "false"
This commit is contained in:
Soonho Kong 2013-09-28 17:52:27 -07:00
parent 4602dfd209
commit 841a1fb20c

View file

@ -6,6 +6,7 @@ Author: Leonardo de Moura
*/
#pragma once
#include <iostream>
#include <typeinfo>
#include "util/exception.h"
#ifndef __has_builtin
@ -106,6 +107,9 @@ public:
virtual char const * what() const noexcept { return "'unreachable' code was reached"; }
};
namespace debug {
template<typename T> void display_var(char const * name, T const & value) { std::cerr << name << " := " << value << "\n"; }
template<typename T> void display_var(char const * name, T const & value) {
std::cerr << name << " : " << typeid(value).name() << " := "
<< std::boolalpha << value << std::noboolalpha
<< std::endl; }
}
}