Deduce type of template type in C++

后端 未结 2 2103
庸人自扰
庸人自扰 2021-02-12 20:20

When writing generic functions for \"iterator\" ranges I usually do:

template  auto func(Iter &first, Iter &last)
{
    using IterTy         


        
2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-12 20:45

    The second is the most idiomatic one.

    • The first does not work with proxies (std::vector < bool > )
    • The third does not work with pointers.

提交回复
热议问题