1

I'd like to define a static constexpr data member in a class, like

class my_protocol
{
public:
    static constexpr auto comm_timeout = 50ms;
    ...
};

Is there a good way to avoid the using namespace std::literals::chrono_literals; at global scope in the header file that defines this class?

Simon Richter
  • 28,572
  • 1
  • 42
  • 64

1 Answers1

2

There is still the lambda directly invoked way:

class my_protocol
{
public:
    static constexpr auto comm_timeout = [](){
        using namespace std::literals::chrono_literals;
        return 50ms;
    }();
    // ...
};
Jarod42
  • 203,559
  • 14
  • 181
  • 302