瀏覽代碼

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

legacy
Sam Hocevar 4 年之前
父節點
當前提交
d40b492d23
共有 3 個文件被更改,包括 14 次插入2 次删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存