Use *_t and *_v trait helpers from C++17 STL (#731)
This commit is contained in:
@@ -156,7 +156,7 @@ template <class A1>
|
||||
struct Descriptor<VertexType<A1>> {
|
||||
using Type = VertexType<A1>;
|
||||
static_assert(sizeof(Type) < 256, "vertex type must be smaller than 256 bytes");
|
||||
static_assert(std::is_standard_layout<Type>::value, "vertex type must use standard layout");
|
||||
static_assert(std::is_standard_layout_v<Type>, "vertex type must use standard layout");
|
||||
static constexpr const VertexDescriptor data = { sizeof(Type), 1, {
|
||||
{ A1::DataType, offsetof(Type, a1) },
|
||||
}};
|
||||
@@ -169,7 +169,7 @@ template <class A1, class A2>
|
||||
struct Descriptor<VertexType<A1, A2>> {
|
||||
using Type = VertexType<A1, A2>;
|
||||
static_assert(sizeof(Type) < 256, "vertex type must be smaller than 256 bytes");
|
||||
static_assert(std::is_standard_layout<Type>::value, "vertex type must use standard layout");
|
||||
static_assert(std::is_standard_layout_v<Type>, "vertex type must use standard layout");
|
||||
static constexpr const VertexDescriptor data = { sizeof(Type), 2, {
|
||||
{ A1::DataType, offsetof(Type, a1) },
|
||||
{ A2::DataType, offsetof(Type, a2) },
|
||||
@@ -183,7 +183,7 @@ template <class A1, class A2, class A3>
|
||||
struct Descriptor<VertexType<A1, A2, A3>> {
|
||||
using Type = VertexType<A1, A2, A3>;
|
||||
static_assert(sizeof(Type) < 256, "vertex type must be smaller than 256 bytes");
|
||||
static_assert(std::is_standard_layout<Type>::value, "vertex type must use standard layout");
|
||||
static_assert(std::is_standard_layout_v<Type>, "vertex type must use standard layout");
|
||||
static constexpr const VertexDescriptor data = { sizeof(Type), 3, {
|
||||
{ A1::DataType, offsetof(Type, a1) },
|
||||
{ A2::DataType, offsetof(Type, a2) },
|
||||
@@ -198,7 +198,7 @@ template <class A1, class A2, class A3, class A4>
|
||||
struct Descriptor<VertexType<A1, A2, A3, A4>> {
|
||||
using Type = VertexType<A1, A2, A3, A4>;
|
||||
static_assert(sizeof(Type) < 256, "vertex type must be smaller than 256 bytes");
|
||||
static_assert(std::is_standard_layout<Type>::value, "vertex type must use standard layout");
|
||||
static_assert(std::is_standard_layout_v<Type>, "vertex type must use standard layout");
|
||||
static constexpr const VertexDescriptor data = { sizeof(Type), 4, {
|
||||
{ A1::DataType, offsetof(Type, a1) },
|
||||
{ A2::DataType, offsetof(Type, a2) },
|
||||
@@ -214,7 +214,7 @@ template <class A1, class A2, class A3, class A4, class A5>
|
||||
struct Descriptor<VertexType<A1, A2, A3, A4, A5>> {
|
||||
using Type = VertexType<A1, A2, A3, A4, A5>;
|
||||
static_assert(sizeof(Type) < 256, "vertex type must be smaller than 256 bytes");
|
||||
static_assert(std::is_standard_layout<Type>::value, "vertex type must use standard layout");
|
||||
static_assert(std::is_standard_layout_v<Type>, "vertex type must use standard layout");
|
||||
static constexpr const VertexDescriptor data = { sizeof(Type), 5, {
|
||||
{ A1::DataType, offsetof(Type, a1) },
|
||||
{ A2::DataType, offsetof(Type, a2) },
|
||||
|
||||
@@ -34,14 +34,14 @@ public:
|
||||
void queryLocations(const ProgramID& id) {
|
||||
locations = Locations{
|
||||
queryLocation(id, concat_literals<&string_literal<'a', '_'>::value, &As::name>::value())... };
|
||||
using TypeOfFirst = typename std::tuple_element<0, std::tuple<As...>>::type;
|
||||
using TypeOfFirst = typename std::tuple_element_t<0, std::tuple<As...>>;
|
||||
auto first = locations.template get<TypeOfFirst>();
|
||||
assert(first && first.value() == 0);
|
||||
}
|
||||
|
||||
static constexpr const char* getFirstAttribName() {
|
||||
// Static assert that attribute list starts with position: we bind it on location 0.
|
||||
using TypeOfFirst = typename std::tuple_element<0, std::tuple<As...>>::type;
|
||||
using TypeOfFirst = typename std::tuple_element_t<0, std::tuple<As...>>;
|
||||
static_assert(std::is_same<attributes::pos, TypeOfFirst>::value || std::is_same<attributes::pos_offset, TypeOfFirst>::value ||
|
||||
std::is_same<attributes::pos_normal, TypeOfFirst>::value, "Program must start with position related attribute.");
|
||||
return concat_literals<&string_literal<'a', '_'>::value, TypeOfFirst::name>::value();
|
||||
|
||||
@@ -24,13 +24,13 @@ using namespace platform;
|
||||
static_assert(underlying_type(ShaderType::Vertex) == GL_VERTEX_SHADER, "OpenGL type mismatch");
|
||||
static_assert(underlying_type(ShaderType::Fragment) == GL_FRAGMENT_SHADER, "OpenGL type mismatch");
|
||||
|
||||
static_assert(std::is_same<ProgramID, GLuint>::value, "OpenGL type mismatch");
|
||||
static_assert(std::is_same<ShaderID, GLuint>::value, "OpenGL type mismatch");
|
||||
static_assert(std::is_same<BufferID, GLuint>::value, "OpenGL type mismatch");
|
||||
static_assert(std::is_same<TextureID, GLuint>::value, "OpenGL type mismatch");
|
||||
static_assert(std::is_same<VertexArrayID, GLuint>::value, "OpenGL type mismatch");
|
||||
static_assert(std::is_same<FramebufferID, GLuint>::value, "OpenGL type mismatch");
|
||||
static_assert(std::is_same<RenderbufferID, GLuint>::value, "OpenGL type mismatch");
|
||||
static_assert(std::is_same_v<ProgramID, GLuint>, "OpenGL type mismatch");
|
||||
static_assert(std::is_same_v<ShaderID, GLuint>, "OpenGL type mismatch");
|
||||
static_assert(std::is_same_v<BufferID, GLuint>, "OpenGL type mismatch");
|
||||
static_assert(std::is_same_v<TextureID, GLuint>, "OpenGL type mismatch");
|
||||
static_assert(std::is_same_v<VertexArrayID, GLuint>, "OpenGL type mismatch");
|
||||
static_assert(std::is_same_v<FramebufferID, GLuint>, "OpenGL type mismatch");
|
||||
static_assert(std::is_same_v<RenderbufferID, GLuint>, "OpenGL type mismatch");
|
||||
|
||||
static_assert(underlying_type(UniformDataType::Float) == GL_FLOAT, "OpenGL type mismatch");
|
||||
static_assert(underlying_type(UniformDataType::FloatVec2) == GL_FLOAT_VEC2, "OpenGL type mismatch");
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace gl {
|
||||
template <typename T>
|
||||
class Enum {
|
||||
public:
|
||||
using InType = std::conditional_t<std::is_same<std::underlying_type_t<T>, bool>::value, platform::GLboolean, platform::GLint>;
|
||||
using OutType = std::conditional_t<std::is_same<std::underlying_type_t<T>, bool>::value, platform::GLboolean, platform::GLenum>;
|
||||
using InType = std::conditional_t<std::is_same_v<std::underlying_type_t<T>, bool>, platform::GLboolean, platform::GLint>;
|
||||
using OutType = std::conditional_t<std::is_same_v<std::underlying_type_t<T>, bool>, platform::GLboolean, platform::GLenum>;
|
||||
|
||||
static T from(InType);
|
||||
static OutType to(T);
|
||||
|
||||
@@ -33,7 +33,7 @@ optional<std::string> Converter<std::string>::operator()(const Convertible& valu
|
||||
}
|
||||
|
||||
template <class T>
|
||||
optional<T> Converter<T, typename std::enable_if_t<std::is_enum<T>::value>>::operator()(const Convertible& value, Error& error) const {
|
||||
optional<T> Converter<T, typename std::enable_if_t<std::is_enum_v<T>>>::operator()(const Convertible& value, Error& error) const {
|
||||
optional<std::string> string = toString(value);
|
||||
if (!string) {
|
||||
error.message = "value must be a string";
|
||||
@@ -50,7 +50,7 @@ optional<T> Converter<T, typename std::enable_if_t<std::is_enum<T>::value>>::ope
|
||||
}
|
||||
|
||||
template <class T>
|
||||
auto Converter<std::vector<T>, typename std::enable_if_t<std::is_enum<T>::value>>::operator()(const Convertible& value, Error& error) const -> optional<std::vector<T>> {
|
||||
auto Converter<std::vector<T>, typename std::enable_if_t<std::is_enum_v<T>>>::operator()(const Convertible& value, Error& error) const -> optional<std::vector<T>> {
|
||||
if (!isArray(value)) {
|
||||
error.message = "value must be an array";
|
||||
return nullopt;
|
||||
|
||||
@@ -48,7 +48,7 @@ void stringify(Writer& writer, const std::string& v) {
|
||||
writer.String(v);
|
||||
}
|
||||
|
||||
template <class Writer, class T, class Enable = std::enable_if_t<std::is_enum<T>::value>>
|
||||
template <class Writer, class T, class Enable = std::enable_if_t<std::is_enum_v<T>>>
|
||||
void stringify(Writer& writer, const T& v) {
|
||||
writer.String(Enum<T>::toString(v));
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ struct SignatureType<R (T::*)(Params...) const>
|
||||
{ using Type = R (Params...); };
|
||||
|
||||
template <class Lambda>
|
||||
struct SignatureType<Lambda, std::enable_if_t<std::is_class<Lambda>::value>>
|
||||
struct SignatureType<Lambda, std::enable_if_t<std::is_class_v<Lambda>>>
|
||||
{ using Type = typename SignatureType<decltype(&Lambda::operator())>::Type; };
|
||||
|
||||
template <typename Fn>
|
||||
|
||||
@@ -279,12 +279,12 @@ optional<Rotation> ValueConverter<Rotation>::fromExpressionValue(const Value& v)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Value ValueConverter<T, std::enable_if_t< std::is_enum<T>::value >>::toExpressionValue(const T& value) {
|
||||
Value ValueConverter<T, std::enable_if_t< std::is_enum_v<T>>>::toExpressionValue(const T& value) {
|
||||
return std::string(Enum<T>::toString(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
optional<T> ValueConverter<T, std::enable_if_t< std::is_enum<T>::value >>::fromExpressionValue(const Value& value) {
|
||||
optional<T> ValueConverter<T, std::enable_if_t<std::is_enum_v<T>>>::fromExpressionValue(const Value& value) {
|
||||
return value.match(
|
||||
[&] (const std::string& v) { return Enum<T>::toEnum(v); },
|
||||
[&] (const auto&) { return optional<T>(); }
|
||||
|
||||
Reference in New Issue
Block a user