NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
istringify.hpp
浏览该文件的文档.
1#ifndef NEFORCE_CORE_INTERFACE_ISTRINGIFY_HPP__
2#define NEFORCE_CORE_INTERFACE_ISTRINGIFY_HPP__
3
12
14NEFORCE_BEGIN_NAMESPACE__
15
21
31template <typename T>
32struct istringify {
33private:
38 constexpr const T& derived() const noexcept { return static_cast<const T&>(*this); }
39
40public:
47 NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string to_string() const { return derived().to_string(); }
48};
49 // CRTPInterfaces
51
57
67template <typename T, enable_if_t<is_base_of_v<istringify<T>, T>, int> = 0>
68NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string to_string(const T& obj) {
69 return obj.to_string();
70}
71 // StringConverts
73
74NEFORCE_END_NAMESPACE__
75#endif // NEFORCE_CORE_INTERFACE_ISTRINGIFY_HPP__
NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string to_string(const T &obj)
将实现了istringify接口的对象转换为字符串
字符串类型别名和实用函数
可字符串化接口
NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string to_string() const
转换为字符串