auto_print.hpp 518 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifndef MIGRAPHX_GUARD_TEST_AUTO_PRINT_HPP
#define MIGRAPHX_GUARD_TEST_AUTO_PRINT_HPP

#include <migraphx/register_target.hpp>
#include <functional>

struct auto_print
{
    static std::function<void()>& get_handler(const std::string& name);
    static void set_terminate_handler(const std::string& name);
    std::string name;
    template <class T>
    auto_print(T& x, std::string s) : name(std::move(s))
    {
        get_handler(name) = [&x] { std::cout << x << std::endl; };
    }

18
    ~auto_print();
19
20
21
};

#endif