// // Created by jedi on 06.02.21. // #pragma once #if __has_include() #include using std::source_location; #elif __has_include() #include using std::experimental::source_location; #else #error " not found" #endif /* template inline void throw_with_pos(const std::string &message = "", const source_location &location = source_location::current()) { std::stringstream ss; ss << location.function_name() << " in " << location.file_name() << ':' << location.line() << ' ' << message; throw ERROR(ss.str()); }*/ #include template struct is_empty : std::false_type { }; template class Z, T... Is> struct is_empty> : std::true_type { }; template class Z, T First, T... Rest> struct is_empty> : std::false_type { }; template struct Z; template struct throw_with_pos { explicit throw_with_pos(std::string_view message = "", T &&... pack, source_location loc = source_location::current()) { std::stringstream ss; ss << loc.function_name() << " in " << loc.file_name() << ':' << loc.line() << ' ' << message; if(!is_empty>::value) ((ss << std::forward(pack)), ...); throw ERROR(ss.str()); } explicit throw_with_pos(const source_location& loc, T &&... pack) { std::stringstream ss; ss << loc.function_name() << " in " << loc.file_name() << ':' << loc.line() << ' '; if(!is_empty>::value) ((ss << std::forward(pack)), ...); throw ERROR(ss.str()); } }; template throw_with_pos(std::string_view, T &&...m) -> throw_with_pos; template throw_with_pos(const source_location&, T &&...m) -> throw_with_pos;