Skip to content

Commit

Permalink
One more revision to synchronized Strutil::print (AcademySoftwareFoun…
Browse files Browse the repository at this point in the history
…dation#3828)

This is a continuation/fix for AcademySoftwareFoundation#3825
  • Loading branch information
lgritz committed May 15, 2023
1 parent 7b6f618 commit c9e7ca6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/include/OpenImageIO/strutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,27 @@ namespace sync {
/// Output is fully thread-safe (the outputs are "atomic" to the file or
/// stream), and if the stream is buffered, it is flushed after the output).

#if FMT_VERSION >= 70000
template<typename Str, typename... Args>
inline void print (FILE *file, const Str& fmt, Args&&... args)
{
sync_output (file, ::fmt::vformat(fmt, ::fmt::make_format_args(args...)));
}

template<typename Str, typename... Args>
inline void print (const Str& fmt, Args&&... args)
{
print(stdout, fmt, std::forward<Args>(args)...);
}

template<typename Str, typename... Args>
inline void print (std::ostream &file, const Str& fmt, Args&&... args)
{
sync_output (file, ::fmt::vformat(fmt, ::fmt::make_format_args(args...)));
}

#else

template<typename... Args>
inline void print (FILE *file, const char* fmt, Args&&... args)
{
Expand All @@ -224,6 +245,7 @@ inline void print (std::ostream &file, const char* fmt, Args&&... args)
{
sync_output (file, ::fmt::format(fmt, std::forward<Args>(args)...));
}
#endif
} // namespace sync


Expand Down

0 comments on commit c9e7ca6

Please sign in to comment.