fmt里判断是否为reference_wrapper

 参考:

一窥模板的替换和匹配方式:偏特化的参数比泛化版本的还要多:判断是不是std::pair<,>。-CSDN博客

C:\work\hchx\HchxKernel\PublicAPI\fmt\args.h

template <typename T> struct is_reference_wrapper : std::false_type {};
template <typename T>
struct is_reference_wrapper<std::reference_wrapper<T>> : std::true_type {};

 一个引用的地方:

template <typename T>
  using stored_type = conditional_t<detail::is_string<T>::value &&
                                        !has_formatter<T, Context>::value &&
                                        !detail::is_reference_wrapper<T>::value,
                                    std::basic_string<char_type>, T>;

reference_wrapper的定义


template<class _Ty>
	class reference_wrapper
		: public _Weak_types<_Ty>::type
{	// stand-in for an assignable reference
public:
	static_assert(is_object_v<_Ty> || is_function_v<_Ty>,
		"reference_wrapper<T> requires T to be an object type or a function type.");

	using type = _Ty;

	template<class _Uty,
		enable_if_t<conjunction_v<
			negation<is_same<remove_cv_t<remove_reference_t<_Uty>>, reference_wrapper>>,
			_Refwrap_has_ctor_from<_Ty, _Uty>>, int> = 0>
		reference_wrapper(_Uty&& _Val)
			_NOEXCEPT_COND(_NOEXCEPT_OPER(_Refwrap_ctor_fun<_Ty>(_STD declval<_Uty>())))
			{	// construct
			_Ty& _Ref = _STD forward<_Uty>(_Val);
			_Ptr = _STD addressof(_Ref);
			}

	operator _Ty&() const noexcept
		{	// return reference
		return (*_Ptr);
		}

	_NODISCARD _Ty& get() const noexcept
		{	// return reference
		return (*_Ptr);
		}

	template<class... _Types>
		auto operator()(_Types&&... _Args) const
		-> decltype(_STD invoke(get(), _STD forward<_Types>(_Args)...))
		{	// invoke object/function
		return (_STD invoke(get(), _STD forward<_Types>(_Args)...));
		}

private:
	_Ty * _Ptr;
	}

相关推荐

  1. fmt判断是否reference_wrapper

    2024-04-28 16:12:03       34 阅读
  2. 判断cursor是否

    2024-04-28 16:12:03       49 阅读
  3. js判断是否数字的方法

    2024-04-28 16:12:03       58 阅读
  4. ES6---判断对象是否{}

    2024-04-28 16:12:03       52 阅读
  5. Go 优雅判断 interface 是否 nil

    2024-04-28 16:12:03       42 阅读
  6. 判断是否闰年?【C语言】

    2024-04-28 16:12:03       38 阅读
  7. Python判断一个数是否素数

    2024-04-28 16:12:03       37 阅读
  8. (vue)判断是否字符串/数组

    2024-04-28 16:12:03       33 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-28 16:12:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-28 16:12:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-28 16:12:03       87 阅读
  4. Python语言-面向对象

    2024-04-28 16:12:03       96 阅读

热门阅读

  1. uniapp 阿里云点播 其他功能

    2024-04-28 16:12:03       34 阅读
  2. 练习题(2024/4/)

    2024-04-28 16:12:03       34 阅读
  3. Cocos Creator 3D物理引擎的物理参数控制详解

    2024-04-28 16:12:03       37 阅读
  4. Python中常用的爬虫库

    2024-04-28 16:12:03       29 阅读
  5. c# 计算总是向上取整

    2024-04-28 16:12:03       37 阅读
  6. 如何有效的开展接口自动化测试?

    2024-04-28 16:12:03       29 阅读
  7. sqlite3

    2024-04-28 16:12:03       35 阅读
  8. MATLAB初学者入门(21)—— 霍夫曼树

    2024-04-28 16:12:03       33 阅读