Compare commits
	
		
			3 Commits
		
	
	
		
			cca34a1ad7
			...
			e724f201fc
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								
									
								
								 | 
						e724f201fc | |
| 
							
							
								
									
								
								 | 
						7fc2b533c7 | |
| 
							
							
								
									
								
								 | 
						33d31af61d | 
| 
						 | 
					@ -2,6 +2,7 @@
 | 
				
			||||||
#include <soi>
 | 
					#include <soi>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
signed main() {
 | 
					signed main() {
 | 
				
			||||||
 | 
					  dbg();
 | 
				
			||||||
  dbg("hi");
 | 
					  dbg("hi");
 | 
				
			||||||
  string s="world";
 | 
					  string s="world";
 | 
				
			||||||
  dbg(s);
 | 
					  dbg(s);
 | 
				
			||||||
| 
						 | 
					@ -18,5 +19,4 @@ signed main() {
 | 
				
			||||||
  dbg(map<int, string>{{3,"three"},{1,"one"}});
 | 
					  dbg(map<int, string>{{3,"three"},{1,"one"}});
 | 
				
			||||||
  dbg(unordered_map<int, string>{{3,"three"},{1,"one"}});
 | 
					  dbg(unordered_map<int, string>{{3,"three"},{1,"one"}});
 | 
				
			||||||
  dbg(unordered_set<int>{3,1,4});
 | 
					  dbg(unordered_set<int>{3,1,4});
 | 
				
			||||||
  dbg();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,7 @@
 | 
				
			||||||
#include <tuple>
 | 
					#include <tuple>
 | 
				
			||||||
#include <type_traits>
 | 
					#include <type_traits>
 | 
				
			||||||
#include <unordered_set>
 | 
					#include <unordered_set>
 | 
				
			||||||
 | 
					#include <unordered_map>
 | 
				
			||||||
#include <utility>
 | 
					#include <utility>
 | 
				
			||||||
#include <valarray>
 | 
					#include <valarray>
 | 
				
			||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,8 +19,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __GNUG__
 | 
					#ifdef __GNUG__
 | 
				
			||||||
#include <cstdlib>
 | 
					#include <cstdlib>
 | 
				
			||||||
#include <memory>
 | 
					 | 
				
			||||||
#include <cxxabi.h>
 | 
					#include <cxxabi.h>
 | 
				
			||||||
 | 
					#include <memory>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 | 
					#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 | 
				
			||||||
| 
						 | 
					@ -36,25 +36,21 @@ namespace detail {
 | 
				
			||||||
// ----------------------------------------------------------------------------
 | 
					// ----------------------------------------------------------------------------
 | 
				
			||||||
// pretty printing the type name
 | 
					// pretty printing the type name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct string_view {
 | 
				
			||||||
struct string_view
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  char const *data;
 | 
					  char const *data;
 | 
				
			||||||
  std::size_t size;
 | 
					  std::size_t size;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template<class T>
 | 
					template <class T> string_view get_name() {
 | 
				
			||||||
constexpr string_view get_name()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  char const *p = __PRETTY_FUNCTION__;
 | 
					  char const *p = __PRETTY_FUNCTION__;
 | 
				
			||||||
    while (*p++ != '=');
 | 
					  while (*p++ != '=')
 | 
				
			||||||
    for (; *p == ' '; ++p);
 | 
					    ;
 | 
				
			||||||
 | 
					  for (; *p == ' '; ++p)
 | 
				
			||||||
 | 
					    ;
 | 
				
			||||||
  char const *p2 = p;
 | 
					  char const *p2 = p;
 | 
				
			||||||
  int count = 1;
 | 
					  int count = 1;
 | 
				
			||||||
    for (;;++p2)
 | 
					  for (;; ++p2) {
 | 
				
			||||||
    {
 | 
					    switch (*p2) {
 | 
				
			||||||
        switch (*p2)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
    case '[':
 | 
					    case '[':
 | 
				
			||||||
      ++count;
 | 
					      ++count;
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
| 
						 | 
					@ -67,11 +63,13 @@ constexpr string_view get_name()
 | 
				
			||||||
  return {};
 | 
					  return {};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
std::string replace_all(std::string str, const std::string& from, const std::string& to) {
 | 
					std::string replace_all(std::string str, const std::string &from,
 | 
				
			||||||
 | 
					                        const std::string &to) {
 | 
				
			||||||
  size_t start_pos = 0;
 | 
					  size_t start_pos = 0;
 | 
				
			||||||
  while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
 | 
					  while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
 | 
				
			||||||
    str.replace(start_pos, from.length(), to);
 | 
					    str.replace(start_pos, from.length(), to);
 | 
				
			||||||
        start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
 | 
					    start_pos +=
 | 
				
			||||||
 | 
					        to.length(); // Handles case where 'to' is a substring of 'from'
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return str;
 | 
					  return str;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -198,16 +196,36 @@ template <typename T> T &&identity(T &&t) { return std::forward<T>(t); }
 | 
				
			||||||
#define dbg(...) dbg_macro::identity(__VA_ARGS__)
 | 
					#define dbg(...) dbg_macro::identity(__VA_ARGS__)
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SOI_ARG16(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, ...) _15
 | 
					#if defined(__clang__)
 | 
				
			||||||
#define SOI_IS_NONEMPTY(...) SOI_ARG16(1, ##__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)
 | 
					
 | 
				
			||||||
 | 
					#define SOI_ARG16(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13,  \
 | 
				
			||||||
 | 
					                  _14, _15, ...)                                               \
 | 
				
			||||||
 | 
					  _15
 | 
				
			||||||
 | 
					#define SOI_IS_NONEMPTY(...)                                                   \
 | 
				
			||||||
 | 
					  SOI_ARG16(1, ##__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SOI_DBG_IMPL_0()                                                       \
 | 
					#define SOI_DBG_IMPL_0()                                                       \
 | 
				
			||||||
  soi::detail::dbg_print_status(__FILE__, __LINE__, __func__)
 | 
					  soi::detail::dbg_print_status(__FILE__, __LINE__, __func__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SOI_DBG_IMPL_1(...)                                                    \
 | 
					#define SOI_DBG_IMPL_1(...)                                                    \
 | 
				
			||||||
  soi::detail::dbg_print((__VA_ARGS__),                                 \
 | 
					  soi::detail::dbg_print(                                                      \
 | 
				
			||||||
 | 
					      (__VA_ARGS__),                                                           \
 | 
				
			||||||
      soi::detail::sanitized_type_name<decltype(__VA_ARGS__)>(), __FILE__,     \
 | 
					      soi::detail::sanitized_type_name<decltype(__VA_ARGS__)>(), __FILE__,     \
 | 
				
			||||||
      __LINE__, __func__, #__VA_ARGS__)
 | 
					      __LINE__, __func__, #__VA_ARGS__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define SOI_IS_NONEMPTY(...) __VA_OPT__(HAS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define SOI_DBG_IMPL_()                                                        \
 | 
				
			||||||
 | 
					  soi::detail::dbg_print_status(__FILE__, __LINE__, __func__)
 | 
				
			||||||
 | 
					#define SOI_DBG_IMPL_HAS(...)                                                  \
 | 
				
			||||||
 | 
					  soi::detail::dbg_print(                                                      \
 | 
				
			||||||
 | 
					      (__VA_ARGS__),                                                           \
 | 
				
			||||||
 | 
					      soi::detail::sanitized_type_name<decltype(__VA_ARGS__)>(), __FILE__,     \
 | 
				
			||||||
 | 
					      __LINE__, __func__, #__VA_ARGS__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SOI_CAT(a, ...) PRIMITIVE_CAT(a, __VA_ARGS__)
 | 
					#define SOI_CAT(a, ...) PRIMITIVE_CAT(a, __VA_ARGS__)
 | 
				
			||||||
#define SOI_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
 | 
					#define SOI_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
 | 
				
			||||||
| 
						 | 
					@ -215,8 +233,7 @@ template <typename T> T &&identity(T &&t) { return std::forward<T>(t); }
 | 
				
			||||||
#define SOI_DBG_IMPL(is_nonempty, ...)                                         \
 | 
					#define SOI_DBG_IMPL(is_nonempty, ...)                                         \
 | 
				
			||||||
  SOI_PRIMITIVE_CAT(SOI_DBG_IMPL_, is_nonempty)(__VA_ARGS__)
 | 
					  SOI_PRIMITIVE_CAT(SOI_DBG_IMPL_, is_nonempty)(__VA_ARGS__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define dbg(...)                                                       \
 | 
					#define dbg(...) SOI_DBG_IMPL(SOI_IS_NONEMPTY(__VA_ARGS__), __VA_ARGS__)
 | 
				
			||||||
  SOI_DBG_IMPL(SOI_IS_NONEMPTY(__VA_ARGS__), __VA_ARGS__)
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // SOI_DBG
 | 
					#endif // SOI_DBG
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue