Photon Common Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
utility.h
Go to the documentation of this file.
1#pragma once
2
3#include "Common/config.h"
4
5#include <string>
6#include <type_traits>
7#include <array>
8#include <cstddef>
9#include <concepts>
10
11namespace ph::detail
12{
13
15 const std::string& filename,
16 const std::string& lineNumber);
17
18}// end namespace ph::detail
19
20#define PH_NOT_IMPLEMENTED_WARNING()\
21 do\
22 {\
23 ::ph::detail::output_not_implemented_warning(\
24 std::string(__FILE__),\
25 std::to_string(__LINE__));\
26 } while(0)
27
28namespace ph
29{
30
33template<typename T>
34consteval std::size_t sizeof_in_bits();
35
39template<typename T, std::size_t N>
40constexpr std::array<T, N> make_array(const T& element);
41
42template<std::integral DstType, std::integral SrcType>
43DstType lossless_integer_cast(const SrcType& src);
44
45template<std::floating_point DstType, std::floating_point SrcType>
46DstType lossless_float_cast(const SrcType& src);
47
53template<typename DstType, typename SrcType>
54DstType lossless_cast(const SrcType& src);
55
56template<typename DstType, typename SrcType>
57DstType lossless_cast(const SrcType& src, DstType* const out_dst);
58
59}// end namespace ph
60
61#include "Common/utility.ipp"
Configurations for the entire toolset.
Implementation detail mainly for internal usages.
Definition assertion.h:9
void output_not_implemented_warning(const std::string &filename, const std::string &lineNumber)
Definition utility.cpp:8
The root for all renderer implementations.
Definition assertion.h:9
DstType lossless_integer_cast(const SrcType &src)
Definition utility.ipp:41
constexpr std::array< T, N > make_array(const T &element)
Creates an std::array filled with the same element.
Definition utility.ipp:35
DstType lossless_cast(const SrcType &src)
Cast numeric value to another type without any loss of information. If there is any possible overflow...
Definition utility.ipp:109
DstType lossless_float_cast(const SrcType &src)
Definition utility.ipp:77
consteval std::size_t sizeof_in_bits()
Calculates number of bits an instance of type T occupies.
Definition utility.ipp:29