Browse Source

base: disable array::data() when the underlying object is a tuple.

legacy
Sam Hocevar 4 years ago
parent
commit
d40b492d23
3 changed files with 14 additions and 2 deletions
  1. +3
    -1
      doc/tutorial/02_cube.cpp
  2. +3
    -1
      doc/tutorial/07_input.cpp
  3. +8
    -0
      src/lol/base/array.h

+ 3
- 1
doc/tutorial/02_cube.cpp View File

@@ -44,9 +44,11 @@ public:
Ticker::Unref(m_camera);
}

struct vertex { vec3 pos, color; };

virtual bool init_draw() override
{
array<vec3, vec3> mesh
array<vertex> mesh
{
// Front vertices/colors
{ vec3(-1.0, -1.0, 1.0), vec3(1.0, 0.0, 1.0) },


+ 3
- 1
doc/tutorial/07_input.cpp View File

@@ -100,9 +100,11 @@ public:
m_matrix = proj * view * model * anim;
}

struct vertex { vec3 pos, color; };

virtual bool init_draw() override
{
array<vec3, vec3> mesh
array<vertex> mesh
{
// Front vertices/colors
{ vec3(-1.0, -1.0, 1.0), vec3(1.0, 0.0, 1.0) },


+ 8
- 0
src/lol/base/array.h View File

@@ -444,6 +444,14 @@ class array : public array_base<std::tuple<T...>, array<T...>>
private:
using array_base<std::tuple<T...>, array<T...>>::array_base;

// Mark these as private: it’s dangerous to use data() with arrays of
// tuples because no assumption should be made about the tuple layout,
// not even the order of its members in memory.
inline void data() {}
inline void data() const {}
inline void bytes() {}
inline void bytes() const {}

public:
// GCC needs this but Clang doesn’t
typedef std::tuple<T...> element_t;


Loading…
Cancel
Save