Fixed -Weverything warning

master
Christophe Riccio ago%!(EXTRA string=8 years)
parent 3a06085edd
commit 82cf733092
  1. 100
      glm/gtx/string_cast.inl

@ -7,6 +7,18 @@
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
template <typename T>
struct cast
{
typedef T value_type;
};
template <>
struct cast<float>
{
typedef double value_type;
};
GLM_FUNC_QUALIFIER std::string format(const char* msg, ...) GLM_FUNC_QUALIFIER std::string format(const char* msg, ...)
{ {
std::size_t const STRING_BUFFER(4096); std::size_t const STRING_BUFFER(4096);
@ -186,7 +198,8 @@ namespace detail
PrefixStr, PrefixStr,
LiteralStr)); LiteralStr));
return detail::format(FormatStr.c_str(), x[0]); return detail::format(FormatStr.c_str(),
static_cast<cast<T>::value_type>(x[0]));
} }
}; };
@ -201,7 +214,9 @@ namespace detail
PrefixStr, PrefixStr,
LiteralStr, LiteralStr)); LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), x[0], x[1]); return detail::format(FormatStr.c_str(),
static_cast<cast<T>::value_type>(x[0]),
static_cast<cast<T>::value_type>(x[1]));
} }
}; };
@ -216,7 +231,10 @@ namespace detail
PrefixStr, PrefixStr,
LiteralStr, LiteralStr, LiteralStr)); LiteralStr, LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), x[0], x[1], x[2]); return detail::format(FormatStr.c_str(),
static_cast<cast<T>::value_type>(x[0]),
static_cast<cast<T>::value_type>(x[1]),
static_cast<cast<T>::value_type>(x[2]));
} }
}; };
@ -231,7 +249,11 @@ namespace detail
PrefixStr, PrefixStr,
LiteralStr, LiteralStr, LiteralStr, LiteralStr)); LiteralStr, LiteralStr, LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), x[0], x[1], x[2], x[3]); return detail::format(FormatStr.c_str(),
static_cast<cast<T>::value_type>(x[0]),
static_cast<cast<T>::value_type>(x[1]),
static_cast<cast<T>::value_type>(x[2]),
static_cast<cast<T>::value_type>(x[3]));
} }
}; };
@ -249,8 +271,8 @@ namespace detail
LiteralStr, LiteralStr)); LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), return detail::format(FormatStr.c_str(),
x[0][0], x[0][1], static_cast<cast<T>::value_type>(x[0][0]), static_cast<cast<T>::value_type>(x[0][1]),
x[1][0], x[1][1]); static_cast<cast<T>::value_type>(x[1][0]), static_cast<cast<T>::value_type>(x[1][1]));
} }
}; };
@ -267,8 +289,8 @@ namespace detail
LiteralStr, LiteralStr, LiteralStr)); LiteralStr, LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), return detail::format(FormatStr.c_str(),
x[0][0], x[0][1], x[0][2], static_cast<cast<T>::value_type>(x[0][0]), static_cast<cast<T>::value_type>(x[0][1]), static_cast<cast<T>::value_type>(x[0][2]),
x[1][0], x[1][1], x[1][2]); static_cast<cast<T>::value_type>(x[1][0]), static_cast<cast<T>::value_type>(x[1][1]), static_cast<cast<T>::value_type>(x[1][2]));
} }
}; };
@ -285,8 +307,8 @@ namespace detail
LiteralStr, LiteralStr, LiteralStr, LiteralStr)); LiteralStr, LiteralStr, LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), return detail::format(FormatStr.c_str(),
x[0][0], x[0][1], x[0][2], x[0][3], static_cast<cast<T>::value_type>(x[0][0]), static_cast<cast<T>::value_type>(x[0][1]), static_cast<cast<T>::value_type>(x[0][2]), static_cast<cast<T>::value_type>(x[0][3]),
x[1][0], x[1][1], x[1][2], x[1][3]); static_cast<cast<T>::value_type>(x[1][0]), static_cast<cast<T>::value_type>(x[1][1]), static_cast<cast<T>::value_type>(x[1][2]), static_cast<cast<T>::value_type>(x[1][3]));
} }
}; };
@ -304,9 +326,9 @@ namespace detail
LiteralStr, LiteralStr)); LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), return detail::format(FormatStr.c_str(),
x[0][0], x[0][1], static_cast<cast<T>::value_type>(x[0][0]), static_cast<cast<T>::value_type>(x[0][1]),
x[1][0], x[1][1], static_cast<cast<T>::value_type>(x[1][0]), static_cast<cast<T>::value_type>(x[1][1]),
x[2][0], x[2][1]); static_cast<cast<T>::value_type>(x[2][0]), static_cast<cast<T>::value_type>(x[2][1]));
} }
}; };
@ -324,9 +346,9 @@ namespace detail
LiteralStr, LiteralStr, LiteralStr)); LiteralStr, LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), return detail::format(FormatStr.c_str(),
x[0][0], x[0][1], x[0][2], static_cast<cast<T>::value_type>(x[0][0]), static_cast<cast<T>::value_type>(x[0][1]), static_cast<cast<T>::value_type>(x[0][2]),
x[1][0], x[1][1], x[1][2], static_cast<cast<T>::value_type>(x[1][0]), static_cast<cast<T>::value_type>(x[1][1]), static_cast<cast<T>::value_type>(x[1][2]),
x[2][0], x[2][1], x[2][2]); static_cast<cast<T>::value_type>(x[2][0]), static_cast<cast<T>::value_type>(x[2][1]), static_cast<cast<T>::value_type>(x[2][2]));
} }
}; };
@ -344,9 +366,9 @@ namespace detail
LiteralStr, LiteralStr, LiteralStr, LiteralStr)); LiteralStr, LiteralStr, LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), return detail::format(FormatStr.c_str(),
x[0][0], x[0][1], x[0][2], x[0][3], static_cast<cast<T>::value_type>(x[0][0]), static_cast<cast<T>::value_type>(x[0][1]), static_cast<cast<T>::value_type>(x[0][2]), static_cast<cast<T>::value_type>(x[0][3]),
x[1][0], x[1][1], x[1][2], x[1][3], static_cast<cast<T>::value_type>(x[1][0]), static_cast<cast<T>::value_type>(x[1][1]), static_cast<cast<T>::value_type>(x[1][2]), static_cast<cast<T>::value_type>(x[1][3]),
x[2][0], x[2][1], x[2][2], x[2][3]); static_cast<cast<T>::value_type>(x[2][0]), static_cast<cast<T>::value_type>(x[2][1]), static_cast<cast<T>::value_type>(x[2][2]), static_cast<cast<T>::value_type>(x[2][3]));
} }
}; };
@ -365,10 +387,10 @@ namespace detail
LiteralStr, LiteralStr)); LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), return detail::format(FormatStr.c_str(),
x[0][0], x[0][1], static_cast<cast<T>::value_type>(x[0][0]), static_cast<cast<T>::value_type>(x[0][1]),
x[1][0], x[1][1], static_cast<cast<T>::value_type>(x[1][0]), static_cast<cast<T>::value_type>(x[1][1]),
x[2][0], x[2][1], static_cast<cast<T>::value_type>(x[2][0]), static_cast<cast<T>::value_type>(x[2][1]),
x[3][0], x[3][1]); static_cast<cast<T>::value_type>(x[3][0]), static_cast<cast<T>::value_type>(x[3][1]));
} }
}; };
@ -387,10 +409,10 @@ namespace detail
LiteralStr, LiteralStr, LiteralStr)); LiteralStr, LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), return detail::format(FormatStr.c_str(),
x[0][0], x[0][1], x[0][2], static_cast<cast<T>::value_type>(x[0][0]), static_cast<cast<T>::value_type>(x[0][1]), static_cast<cast<T>::value_type>(x[0][2]),
x[1][0], x[1][1], x[1][2], static_cast<cast<T>::value_type>(x[1][0]), static_cast<cast<T>::value_type>(x[1][1]), static_cast<cast<T>::value_type>(x[1][2]),
x[2][0], x[2][1], x[2][2], static_cast<cast<T>::value_type>(x[2][0]), static_cast<cast<T>::value_type>(x[2][1]), static_cast<cast<T>::value_type>(x[2][2]),
x[3][0], x[3][1], x[3][2]); static_cast<cast<T>::value_type>(x[3][0]), static_cast<cast<T>::value_type>(x[3][1]), static_cast<cast<T>::value_type>(x[3][2]));
} }
}; };
@ -409,10 +431,10 @@ namespace detail
LiteralStr, LiteralStr, LiteralStr, LiteralStr)); LiteralStr, LiteralStr, LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), return detail::format(FormatStr.c_str(),
x[0][0], x[0][1], x[0][2], x[0][3], static_cast<cast<T>::value_type>(x[0][0]), static_cast<cast<T>::value_type>(x[0][1]), static_cast<cast<T>::value_type>(x[0][2]), static_cast<cast<T>::value_type>(x[0][3]),
x[1][0], x[1][1], x[1][2], x[1][3], static_cast<cast<T>::value_type>(x[1][0]), static_cast<cast<T>::value_type>(x[1][1]), static_cast<cast<T>::value_type>(x[1][2]), static_cast<cast<T>::value_type>(x[1][3]),
x[2][0], x[2][1], x[2][2], x[2][3], static_cast<cast<T>::value_type>(x[2][0]), static_cast<cast<T>::value_type>(x[2][1]), static_cast<cast<T>::value_type>(x[2][2]), static_cast<cast<T>::value_type>(x[2][3]),
x[3][0], x[3][1], x[3][2], x[3][3]); static_cast<cast<T>::value_type>(x[3][0]), static_cast<cast<T>::value_type>(x[3][1]), static_cast<cast<T>::value_type>(x[3][2]), static_cast<cast<T>::value_type>(x[3][3]));
} }
}; };
@ -428,7 +450,11 @@ namespace detail
PrefixStr, PrefixStr,
LiteralStr, LiteralStr, LiteralStr, LiteralStr)); LiteralStr, LiteralStr, LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), x[0], x[1], x[2], x[3]); return detail::format(FormatStr.c_str(),
static_cast<cast<T>::value_type>(x[0]),
static_cast<cast<T>::value_type>(x[1]),
static_cast<cast<T>::value_type>(x[2]),
static_cast<cast<T>::value_type>(x[3]));
} }
}; };
@ -443,7 +469,15 @@ namespace detail
PrefixStr, PrefixStr,
LiteralStr, LiteralStr, LiteralStr, LiteralStr)); LiteralStr, LiteralStr, LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(), x.real[0], x.real[1], x.real[2], x.real[3], x.dual[0], x.dual[1], x.dual[2], x.dual[3]); return detail::format(FormatStr.c_str(),
static_cast<cast<T>::value_type>(x.real[0]),
static_cast<cast<T>::value_type>(x.real[1]),
static_cast<cast<T>::value_type>(x.real[2]),
static_cast<cast<T>::value_type>(x.real[3]),
static_cast<cast<T>::value_type>(x.dual[0]),
static_cast<cast<T>::value_type>(x.dual[1]),
static_cast<cast<T>::value_type>(x.dual[2]),
static_cast<cast<T>::value_type>(x.dual[3]));
} }
}; };

Loading…
Cancel
Save