aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/features/utils.hpp
blob: 97de3e42d1bf02400e8c0e56ff0a2ebf0b34e2c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "utils.h"
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/exceptions.h>

namespace search::features::util {

template <typename T>
T strToNum(vespalib::stringref str)
{
    vespalib::asciistream iss(str);
    T retval = 0;
    try {
        iss >> retval;
    } catch (const vespalib::IllegalArgumentException &) {
    }
    return retval;
}

}