diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-03 12:44:36 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-08 08:09:29 -0800 |
commit | d1e2fe511ebf6d4aebbb08b2f0aba32e26c6edeb (patch) | |
tree | 6ca51ffe1a62f8e93af7fdff14b21e13e0e37b0f /src/mbgl/gl/attribute.hpp | |
parent | 1db2ffbc1b69069eca39f786cacc45dbb02c3052 (diff) | |
download | qtlocation-mapboxgl-d1e2fe511ebf6d4aebbb08b2f0aba32e26c6edeb.tar.gz |
[core] Introduce and use IndexedTuple
Diffstat (limited to 'src/mbgl/gl/attribute.hpp')
-rw-r--r-- | src/mbgl/gl/attribute.hpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp index a2b165fa21..47f93f31f9 100644 --- a/src/mbgl/gl/attribute.hpp +++ b/src/mbgl/gl/attribute.hpp @@ -2,11 +2,10 @@ #include <mbgl/gl/types.hpp> #include <mbgl/util/ignore.hpp> +#include <mbgl/util/indexed_tuple.hpp> #include <cstddef> #include <functional> -#include <tuple> -#include <utility> namespace mbgl { namespace gl { @@ -143,27 +142,24 @@ void bindAttribute(AttributeLocation location, template <class... As> class Attributes { public: - using State = std::tuple<typename As::State...>; + using State = IndexedTuple<TypeList<As...>, TypeList<typename As::State...>>; using Vertex = detail::Vertex<As...>; + template <class A> + static constexpr std::size_t Index = TypeIndex<A, As...>::value; + static State state(const ProgramID& id) { return State { { attributeLocation(id, As::name) }... }; } static std::function<void (std::size_t)> binder(const State& state) { - return binder(state, std::index_sequence_for<As...>()); - } - -private: - template <std::size_t... Is> - static std::function<void (std::size_t)> binder(const State& state, std::index_sequence<Is...>) { return [&state] (std::size_t vertexOffset) { - ignore((bindAttribute(std::get<Is>(state).location, - std::get<Is>(state).count, - std::get<Is>(state).type, - sizeof(Vertex), - vertexOffset, - Vertex::attributeOffsets[Is]), 0)...); + ignore({ (bindAttribute(state.template get<As>().location, + state.template get<As>().count, + state.template get<As>().type, + sizeof(Vertex), + vertexOffset, + Vertex::attributeOffsets[Index<As>]), 0)... }); }; } }; |