This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UT_OVERLOAD | |
#define UT_OVERLOAD | |
namespace ut { | |
/** | |
* Create an overload set for lambdas | |
* | |
* Requires C++17 | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UT_ASIS | |
#define UT_ASIS | |
#include <memory> | |
#include <type_traits> | |
namespace ut { | |
/** | |
* Try to downcast from reference type `From` to pointer to `To`. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! A very basic utility to manage date and time in UTC timezone. | |
//! | |
//! Usage: | |
//! | |
//! ```zig | |
//! // The following examples assume that the current date and time is 25th May 1977, at 08:48 PM | |
//! const now = DateTime.now(); | |
//! std.debug.print("{}\n", .{now}); // 1977-05-25 20:48:00 | |
//! std.debug.print("{%d %B %Y at %I}:{%M %p}\n", .{ now, now }); // 25 May 1977 at 08:48 PM | |
//! // NOTE: the format string has to be split in two, because `:` is a special character in fmt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UT_CHECK_HPP | |
#define UT_CHECK_HPP | |
/// Class for checking when a c++ object is constructed, copied, moved from or destructed | |
/* Usage: | |
* | |
* std >= c++11 | |
* | |
* #include "check.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UT_CONSTEXPR_HASH_HPP | |
#define UT_CONSTEXPR_HASH_HPP | |
#include <string_view> | |
/* Usage: | |
* | |
* int main(int argc, char const **argv) { | |
* constexpr auto hash = ut::fnv_1a<>; // defaults to uint64_t | |
* | |
* for (int i = 1; i < argc; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UT_ADD_NOEXCEPT_H | |
#define UT_ADD_NOEXCEPT_H | |
namespace ut { | |
/* Add noexcept to function type | |
* | |
* std >= c++17 | |
*/ | |
/* Usage: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UT_CHANGE_OBSERVER | |
#define UT_CHANGE_OBSERVER | |
#include <functional> | |
#include <type_traits> | |
#include <vector> | |
namespace ut { | |
// NOTE: There's 2 versions of several member functions because if the move |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A small script to fix the datetime of jpg files in a directory. | |
It copies the exif datetime to the file's mtime and vice versa. | |
This can fix various importing issues with photo management software (e.g. Google photos). | |
NOTE: This script uses the piexif library to read and write exif data, you will need to install it. | |
NOTE 2: This script will overwrite the mtime of the files. If you use the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UT_COPY_TRAITS | |
#define UT_COPY_TRAITS | |
/** | |
* Usage: | |
* std >= c++20 | |
* | |
* using A = int; | |
* using B = float; | |
* using C = copy_cvref_t<A, B>; // decltype(C) == float |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---Inspect a value | |
--- | |
---Converts nil, boolean, number, string or table to string | |
---Any other type is converted with `tostring`. | |
--- | |
---List-like tables are printed without their indices | |
--- | |
---Usage: | |
--- | |
---```lua |
NewerOlder