gpt4 book ai didi

c++ - 一种缩短声明的方法

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:35:59 25 4
gpt4 key购买 nike

我有这样的东西:

 template<class Key,
class Value,
class Compare_p = Compare<ByKey>,
template<class,class> class Insert_p = NoOverride,
template<class> class FailureSignal_p = ThrowOnFailure,
class AllocFactor_p = AllocFactorScientific<>,
class Alloc = Allocator<FailureSignal_p>
>
class Map : private Map_Base<Implementation> //Implementation is a Link with identical
//params to Map
{
public:
//I've tried to use typedef here but it's too late
typedef LinkImplementation<Pair<Key,Value>,Compare_p,Insert_p,FailureSignal_p,AllocFactor_p,Alloc> Implementation;
};

所以最大的问题是:有没有办法缩短这个声明(LinkImplementation<>)?

最佳答案

也许可以像这样为 map 参数创建一个模板“结构”:

template <class Key, ...  blablabla > struct MapParams{typedef Key key_t;typedef Value value_t;..................};

然后使用这个“结构”作为一个单一的模板参数用于 Map 和 Map_Base 模板?

关于c++ - 一种缩短声明的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4389983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com