General Purpose library for Freestanding C++ and POSIX systems
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

116 行
1.9 KiB

#pragma once
#include "gp_config.hpp"
namespace gp{
class runtime_error{
protected:
const char* what_str;
public:
runtime_error(const char* what)
: what_str{what}
{}
runtime_error()
{
what_str = "an unknown error has occured";
}
const char* what()
{
return what_str;
}
};
class out_of_range : public runtime_error{
public:
out_of_range(const char* what)
: runtime_error{what}
{}
out_of_range()
: runtime_error{}
{
what_str = "out_of_range error has occured";
}
};
class bad_optional : public runtime_error{
public:
bad_optional(const char* what)
: runtime_error{what}
{}
bad_optional()
: runtime_error{}
{
what_str = "bad_optional error has occured";
}
};
template<typename orig, typename target>
class bad_buffer_cast : public runtime_error{
public:
bad_buffer_cast(const char* what)
: runtime_error{what}
{}
bad_buffer_cast()
: runtime_error{}
{
what_str = "bad_buffer_cast error has occured";
}
};
template<typename Expected>
class bad_variant_access : public runtime_error{
public:
bad_variant_access(const char* what)
: runtime_error{what}
{}
bad_variant_access()
: runtime_error{}
{
what_str = "bad_variant_access error has occured";
}
};
class bad_hashmap_access : public runtime_error{
public:
bad_hashmap_access(const char* what)
: runtime_error{what}
{}
bad_hashmap_access()
: runtime_error{}
{
what_str = "bad_hashmap_access error has occured";
}
};
class bad_alloc : public runtime_error{
public:
bad_alloc(const char* what)
: runtime_error{what}
{}
bad_alloc()
: runtime_error{}
{
what_str = "bad_alloc error has occured";
}
};
class bad_functor : public runtime_error{
public:
bad_functor(const char* what)
: runtime_error{what}
{}
bad_functor()
: runtime_error{}
{
what_str = "bad_functor error has occured";
}
};
}