3 KB、90行 生 Blame 履歴
1/// @ref gtx_structured_bindings
2/// @file glm/gtx/structured_bindings.hpp
3///
4/// @defgroup gtx_structured_bindings GLM_GTX_structured_bindings
5/// @ingroup gtx
6///
7/// Include <glm/gtx/structured_bindings.hpp> to use the features of this extension.
8
9#pragma once
10
11// Dependency:
12#include "../glm.hpp"
13#include "../gtx/quaternion.hpp"
14
15#ifdef __cpp_structured_bindings
16#if __cpp_structured_bindings >= 201606L
17#include <utility>
18#include <cstddef>
19namespace std {
20 template<glm::length_t L,typename T,glm::qualifier Q>
21 struct tuple_size<glm::vec<L, T, Q>> {
22 static constexpr size_t value = L;
23 };
24 template<glm::length_t C,glm::length_t R, typename T, glm::qualifier Q>
25 struct tuple_size<glm::mat<C,R, T, Q>> {
26 static constexpr size_t value = C;
27 };
28 template<typename T, glm::qualifier Q>
29 struct tuple_size<glm::qua<T, Q>> {
30 static constexpr size_t value = 4;
31 };
32 template<std::size_t I,glm::length_t L,typename T,glm::qualifier Q>
33 struct tuple_element<I, glm::vec<L,T,Q>>
34 {
35 static_assert(I < L,"Index out of bounds");
36 typedef T type;
37 };
38 template<std::size_t I, glm::length_t C, glm::length_t R, typename T, glm::qualifier Q>
39 struct tuple_element<I, glm::mat<C,R, T, Q>>
40 {
41 static_assert(I < C, "Index out of bounds");
42 typedef glm::vec<R,T,Q> type;
43 };
44 template<std::size_t I, typename T, glm::qualifier Q>
45 struct tuple_element<I, glm::qua<T, Q>>
46 {
47 static_assert(I < 4, "Index out of bounds");
48 typedef T type;
49 };
50
51}
52#endif
53#endif
54
55#ifndef GLM_ENABLE_EXPERIMENTAL
56# error "GLM: GLM_GTX_iteration is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
57#elif GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
58# pragma message("GLM: GLM_GTX_io extension included")
59#endif
60
61namespace glm
62{
63 /// @addtogroup gtx_structured_bindings
64 /// @{
65
66 template<length_t I, length_t L, typename T, qualifier Q>
67 GLM_FUNC_DECL GLM_CONSTEXPR T& get(vec<L, T, Q>& v);
68 template<length_t I, length_t L, typename T, qualifier Q>
69 GLM_FUNC_DECL GLM_CONSTEXPR T const& get(vec<L, T, Q> const& v);
70
71 template<length_t I, length_t C, length_t R, typename T, qualifier Q>
72 GLM_FUNC_DECL GLM_CONSTEXPR vec<R, T, Q>& get(mat<C, R, T, Q>& m);
73 template<length_t I, length_t C, length_t R, typename T, qualifier Q>
74 GLM_FUNC_DECL GLM_CONSTEXPR vec<R, T, Q> const& get(mat<C, R, T, Q> const& m);
75
76 template<length_t I, typename T, qualifier Q>
77 GLM_FUNC_DECL GLM_CONSTEXPR T& get(qua<T, Q>& q);
78 template<length_t I, typename T, qualifier Q>
79 GLM_FUNC_DECL GLM_CONSTEXPR T const& get(qua<T, Q> const& q);
80
81 template<length_t I, length_t L,typename T, qualifier Q>
82 GLM_FUNC_DECL GLM_CONSTEXPR T get(vec<L,T, Q> const&& v);
83 template<length_t I,length_t C,length_t R, typename T, qualifier Q>
84 GLM_FUNC_DECL GLM_CONSTEXPR vec<R,T,Q> get(mat<C,R,T, Q> const&& m);
85 template<length_t I, typename T, qualifier Q>
86 GLM_FUNC_DECL GLM_CONSTEXPR T get(qua<T, Q> const&& q);
87 /// @}
88}//namespace glm
89
90#include "structured_bindings.inl"