What is the difference between a trait and a policy?

前端 未结 4 1402
天命终不由人
天命终不由人 2021-01-29 18:18

I have a class whose behavior I am trying to configure.

template ServerTraits;

Then later on I h

4条回答
  •  一生所求
    2021-01-29 18:44

    If you're using ModeT, IsReentrant, and IsAsync to control the behaviour of the Server, then it's a policy.

    Alternatively, if you are want a way to describe the characteristics of the server to another object, then you could define a traits class like so:

    template 
    class ServerTraits;
    
    template<>
    class ServerTraits
    {
        enum { ModeT = SomeNamespace::MODE_NORMAL };
        static const bool IsReentrant = true;
        static const bool IsAsync = true;
    }
    

提交回复
热议问题