Repository: skyline-emu/skyline
File: app/src/main/cpp/skyline/common.h (C/C++)

Code before:
        constexpr ResultValue(ResultValue<U> result) : result(result) {};

        constexpr operator Result() const {
            return result;
        }

        explicit constexpr operator bool() const {
            return value.has_value();
        }

        constexpr T& operator*()  {
            return *value;
        }

        constexpr T* operator->()  {
            return &*value;
        }
    };

    namespace constant {
        // Time
        constexpr u64 NsInSecond{1000000000}; //!< The amount of nanoseconds in a second
        constexpr u64 NsInMillisecond{1000000}; //!< The amount of nanoseconds in a millisecond
        constexpr u64 NsInDay{86400000000000UL}; //!< The amount of nanoseconds in a day
    }

    namespace util {
        /**
         * @brief A way to implicitly cast all pointers to uintptr_t, this is used for {fmt} as we use 0x{:X} to print pointers
         * @note There's the exception of signed char pointers as they represent C Strings
         * @note This does not cover std::shared_ptr or std::unique_ptr and those will have to be explicitly casted to uintptr_t or passed through fmt::ptr
         */
        template<typename T>
        constexpr auto FmtCast(T object) {
            if constexpr (std::is_pointer<T>::value)
                if constexpr (std::is_same<char, typename std::remove_cv<typename std::remove_pointer<T>::type>::type>::value)
                    return reinterpret_cast<typename std::common_type<char *, T>::type>(object);
                else
                    return reinterpret_cast<const uintptr_t>(object);
            else
                return object;
        }

        /**
         * @brief {fmt}::format but with FmtCast built into it
         */
        template<typename S, typename... Args>
        auto Format(S formatString, Args &&... args) {
            return fmt::format(formatString, FmtCast(args)...);
        }
    }

Review comment (suggestion):
```suggestion
        constexpr u64 NsInMicrosecond{1000}; //!< The amount of nanoseconds in a microsecond
```

Code after:
        constexpr ResultValue(ResultValue<U> result) : result(result) {};

        constexpr operator Result() const {
            return result;
        }

        explicit constexpr operator bool() const {
            return value.has_value();
        }

        constexpr T& operator*()  {
            return *value;
        }

        constexpr T* operator->()  {
            return &*value;
        }
    };

    namespace constant {
        // Time
        constexpr u64 NsInMicrosecond{1000}; //!< The amount of nanoseconds in a microsecond
        constexpr u64 NsInSecond{1000000000}; //!< The amount of nanoseconds in a second
        constexpr u64 NsInMillisecond{1000000}; //!< The amount of nanoseconds in a millisecond
        constexpr u64 NsInDay{86400000000000UL}; //!< The amount of nanoseconds in a day
    }

    namespace util {
        /**
         * @brief A way to implicitly cast all pointers to uintptr_t, this is used for {fmt} as we use 0x{:X} to print pointers
         * @note There's the exception of signed char pointers as they represent C Strings
         * @note This does not cover std::shared_ptr or std::unique_ptr and those will have to be explicitly casted to uintptr_t or passed through fmt::ptr
         */
        template<typename T>
        constexpr auto FmtCast(T object) {
            if constexpr (std::is_pointer<T>::value)
                if constexpr (std::is_same<char, typename std::remove_cv<typename std::remove_pointer<T>::type>::type>::value)
                    return reinterpret_cast<typename std::common_type<char *, T>::type>(object);
                else
                    return reinterpret_cast<const uintptr_t>(object);
            else
                return object;
        }

        /**
         * @brief {fmt}::format but with FmtCast built into it
         */
        template<typename S, typename... Args>
        auto Format(S formatString, Args &&... args) {
            return fmt::format(formatString, FmtCast(args)...);
        }