Added noexcept to most of details::os functions
This commit is contained in:
		
							parent
							
								
									8bd4c87d2f
								
							
						
					
					
						commit
						98f9cb8c1f
					
				@ -57,7 +57,7 @@ namespace spdlog {
 | 
			
		||||
namespace details {
 | 
			
		||||
namespace os {
 | 
			
		||||
 | 
			
		||||
inline spdlog::log_clock::time_point now()
 | 
			
		||||
inline spdlog::log_clock::time_point now() noexcept
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
 | 
			
		||||
@ -70,7 +70,7 @@ inline spdlog::log_clock::time_point now()
 | 
			
		||||
    return log_clock::now();
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
inline std::tm localtime(const std::time_t &time_tt)
 | 
			
		||||
inline std::tm localtime(const std::time_t &time_tt) noexcept
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
@ -83,13 +83,13 @@ inline std::tm localtime(const std::time_t &time_tt)
 | 
			
		||||
    return tm;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline std::tm localtime()
 | 
			
		||||
inline std::tm localtime() noexcept
 | 
			
		||||
{
 | 
			
		||||
    std::time_t now_t = time(nullptr);
 | 
			
		||||
    return localtime(now_t);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline std::tm gmtime(const std::time_t &time_tt)
 | 
			
		||||
inline std::tm gmtime(const std::time_t &time_tt) noexcept
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
@ -102,18 +102,18 @@ inline std::tm gmtime(const std::time_t &time_tt)
 | 
			
		||||
    return tm;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline std::tm gmtime()
 | 
			
		||||
inline std::tm gmtime() noexcept
 | 
			
		||||
{
 | 
			
		||||
    std::time_t now_t = time(nullptr);
 | 
			
		||||
    return gmtime(now_t);
 | 
			
		||||
}
 | 
			
		||||
inline bool operator==(const std::tm &tm1, const std::tm &tm2)
 | 
			
		||||
inline bool operator==(const std::tm &tm1, const std::tm &tm2) noexcept
 | 
			
		||||
{
 | 
			
		||||
    return (tm1.tm_sec == tm2.tm_sec && tm1.tm_min == tm2.tm_min && tm1.tm_hour == tm2.tm_hour && tm1.tm_mday == tm2.tm_mday &&
 | 
			
		||||
            tm1.tm_mon == tm2.tm_mon && tm1.tm_year == tm2.tm_year && tm1.tm_isdst == tm2.tm_isdst);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline bool operator!=(const std::tm &tm1, const std::tm &tm2)
 | 
			
		||||
inline bool operator!=(const std::tm &tm1, const std::tm &tm2) noexcept
 | 
			
		||||
{
 | 
			
		||||
    return !(tm1 == tm2);
 | 
			
		||||
}
 | 
			
		||||
@ -176,7 +176,7 @@ inline bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mod
 | 
			
		||||
    return *fp == nullptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline int remove(const filename_t &filename)
 | 
			
		||||
inline int remove(const filename_t &filename) noexcept
 | 
			
		||||
{
 | 
			
		||||
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
 | 
			
		||||
    return _wremove(filename.c_str());
 | 
			
		||||
@ -185,7 +185,7 @@ inline int remove(const filename_t &filename)
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline int rename(const filename_t &filename1, const filename_t &filename2)
 | 
			
		||||
inline int rename(const filename_t &filename1, const filename_t &filename2) noexcept
 | 
			
		||||
{
 | 
			
		||||
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
 | 
			
		||||
    return _wrename(filename1.c_str(), filename2.c_str());
 | 
			
		||||
@ -195,7 +195,7 @@ inline int rename(const filename_t &filename1, const filename_t &filename2)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Return if file exists
 | 
			
		||||
inline bool file_exists(const filename_t &filename)
 | 
			
		||||
inline bool file_exists(const filename_t &filename)  noexcept
 | 
			
		||||
{
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
#ifdef SPDLOG_WCHAR_FILENAMES
 | 
			
		||||
@ -323,7 +323,7 @@ inline int utc_minutes_offset(const std::tm &tm = details::os::localtime())
 | 
			
		||||
// Return current thread id as size_t
 | 
			
		||||
// It exists because the std::this_thread::get_id() is much slower(especially
 | 
			
		||||
// under VS 2013)
 | 
			
		||||
inline size_t _thread_id()
 | 
			
		||||
inline size_t _thread_id() noexcept
 | 
			
		||||
{
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
    return static_cast<size_t>(::GetCurrentThreadId());
 | 
			
		||||
@ -346,7 +346,7 @@ inline size_t _thread_id()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Return current thread id as size_t (from thread local storage)
 | 
			
		||||
inline size_t thread_id()
 | 
			
		||||
inline size_t thread_id() noexcept
 | 
			
		||||
{
 | 
			
		||||
#if defined(SPDLOG_DISABLE_TID_CACHING) || (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__cplusplus_winrt) ||                       \
 | 
			
		||||
    (defined(__clang__) && !__has_feature(cxx_thread_local))
 | 
			
		||||
@ -359,7 +359,7 @@ inline size_t thread_id()
 | 
			
		||||
 | 
			
		||||
// This is avoid msvc issue in sleep_for that happens if the clock changes.
 | 
			
		||||
// See https://github.com/gabime/spdlog/issues/609
 | 
			
		||||
inline void sleep_for_millis(int milliseconds)
 | 
			
		||||
inline void sleep_for_millis(int milliseconds) noexcept
 | 
			
		||||
{
 | 
			
		||||
#if defined(_WIN32)
 | 
			
		||||
    ::Sleep(milliseconds);
 | 
			
		||||
@ -396,7 +396,7 @@ inline int pid()
 | 
			
		||||
 | 
			
		||||
// Determine if the terminal supports colors
 | 
			
		||||
// Source: https://github.com/agauniyal/rang/
 | 
			
		||||
inline bool is_color_terminal()
 | 
			
		||||
inline bool is_color_terminal() noexcept
 | 
			
		||||
{
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
    return true;
 | 
			
		||||
@ -418,7 +418,7 @@ inline bool is_color_terminal()
 | 
			
		||||
 | 
			
		||||
// Detrmine if the terminal attached
 | 
			
		||||
// Source: https://github.com/agauniyal/rang/
 | 
			
		||||
inline bool in_terminal(FILE *file)
 | 
			
		||||
inline bool in_terminal(FILE *file) noexcept
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user