lundi 25 septembre 2017

Template method not found for uint64_t, though works for int64_t

I have a template method which works with int64_t, but not with uint64_t as type.

This code here:

res = edit_distance_dp< uint64_t >(ap, *asizep, bp, *bsizep); 

Raises the error:

 No matching member function for call to 'edit_distance_dp'

This is odd, because it works with int64_t. This is the template method I'm trying to call:

    template <typename T>
    uint64_t edit_distance_dp(const T  *str1, const uint64_t size1, const T *str2, const uint64_t size2) {
        // vectorより固定長配列の方が速いが、文字列が長い時の保険でのみ呼ばれるのでサイズを決め打ちできない
        vector< vector<uint64_t> > d(size1 + 1, vector<uint64_t>(size2 + 1));
        for (uint64_t i = 0; i < size1 + 1; i++) d[i][0] = i;
        for (uint64_t i = 0; i < size2 + 1; i++) d[0][i] = i;
        for (uint64_t i = 1; i < size1 + 1; i++) {
            for (uint64_t j = 1; j < size2 + 1; j++) {
                d[i][j] = min(min(d[i-1][j], d[i][j-1]) + 1, d[i-1][j-1] + (str1[i-1] == str2[j-1] ? 0 : 1));
            }
        }
        return d[size1][size2];
    }

I would assume it to just work. What's going on here?

Aucun commentaire:

Enregistrer un commentaire