How to use source_location in a variadic template function?

后端 未结 4 916
悲哀的现实
悲哀的现实 2020-12-04 18:07

The C++20 feature std::source_location is used to capture information about the context in which a function is called. When I try to use it with a variadic tem

4条回答
  •  醉话见心
    2020-12-04 18:32

    Not a great solution but... what about place the variadic arguments in a std::tuple?

    I mean... something as

    template 
    void debug (std::tuple && t_args,
                std::source_location const & loc = std::source_location::current());
    

    Unfortunately, this way you have to explicitly call std::make_tuple calling it

    debug(std::make_tuple(1, 2l, 3ll));
    

提交回复
热议问题