Template Function iox::cxx::from

Function Documentation

template<typename F, typename T>
constexpr T iox::cxx::from(const F value) noexcept

Converts a value of type F to a corresponding value of type T. This function needs to be specialized by the user for the types to be converted.

enum class LowLevel
{
    FileDescriptorInvalid,
    FileDescriptorCorrupt,
    Timeout
};

enum class HighLevel
{
    FileDescriptorError,
    Timeout
};

namespace iox
{
namespace cxx
{
template <>
constexpr HighLevel from<LowLevel, HighLevel>(LowLevel e) noexcept
{
    switch (e)
    {
    case LowLevel::FileDescriptorCorrupt:
        return HighLevel::FileDescriptorError;
    case LowLevel::FileDescriptorInvalid:
        return HighLevel::FileDescriptorError;
    case LowLevel::Timeout:
        return HighLevel::Timeout;
    }
}
} // namespace cxx
} // namespace iox

Template Parameters:
  • F – is the ‘from’ type

  • T – is the ‘to’ type

Parameters:

value[in] of type F to convert to T

Returns:

converted value of F to corresponding value of T