// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include #include #include namespace search::attribute { // for all integers template constexpr T getUndefined() { return std::numeric_limits::min(); } template <> inline constexpr float getUndefined() { return -std::numeric_limits::quiet_NaN(); } template <> inline constexpr double getUndefined() { return -std::numeric_limits::quiet_NaN(); } template <> inline constexpr const char* getUndefined() { return ""; } // for all signed integers template bool isUndefined(const T & value) { return value == getUndefined(); } template <> inline bool isUndefined(const uint8_t &) { return false; } template <> inline bool isUndefined(const uint16_t &) { return false; } template <> inline bool isUndefined(const uint32_t &) { return false; } template <> inline bool isUndefined(const uint64_t &) { return false; } template <> inline bool isUndefined(const float & value) { return std::isnan(value); } template <> inline bool isUndefined(const double & value) { return std::isnan(value); } template <> inline bool isUndefined(const vespalib::string & value) { return value.empty(); } }