Специализни шаблонца! (udpn) wrote,
Специализни шаблонца!
udpn

9 лет всё та же самая история

template <class T, T ptr>
struct make_call {
    static const size_t init_size = 128;
    template <class... U>
    wstring operator() (U... args) {
        size_t curr_size = init_size;
        wstring res(curr_size, L'X');
        decltype(ptr(args..., &res[0], curr_size)) ret_size;
        while ((ret_size = ptr(args..., &res[0], curr_size)) + 1 == curr_size) {
            curr_size *= 2;
            res.resize(curr_size);
        }
        return res.substr(0, ret_size);
    }
};
auto GetProcessImageFileNameX = make_call<decltype(GetProcessImageFileNameA), GetProcessImageFileNameA>();
>> fatal error C1001: An internal error has occurred in the compiler.
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 4 comments