WiP allow users to give a separate storage that is not the vector_type.
It works but it's probably not respecting the strict aliasing rule.
This commit is contained in:
parent
a4184811b1
commit
ebfcc6f6ac
6 changed files with 76 additions and 10 deletions
52
test/unit/test_custom_storage.cpp
Normal file
52
test/unit/test_custom_storage.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright 2015-2017 Michele "King_DuckZ" Santullo
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "vectorwrapper/vectorwrapper.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace {
|
||||
struct VecType {
|
||||
int a, b, c;
|
||||
};
|
||||
} //unnamed namespace
|
||||
|
||||
namespace vwr {
|
||||
template <>
|
||||
struct VectorWrapperInfo<VecType> {
|
||||
enum { dimensions = 3};
|
||||
typedef int scalar_type;
|
||||
typedef int storage_type[3];
|
||||
enum {
|
||||
offset_x = offsetof(VecType, a),
|
||||
offset_y = offsetof(VecType, b),
|
||||
offset_z = offsetof(VecType, c)
|
||||
};
|
||||
};
|
||||
} //namespace vwr
|
||||
|
||||
namespace {
|
||||
typedef vwr::Vec<VecType> ivec3;
|
||||
} //unnamed namespace
|
||||
|
||||
TEST(vwr, custom_storage_type) {
|
||||
ivec3 v(55);
|
||||
|
||||
EXPECT_EQ(v.x(), 55);
|
||||
EXPECT_EQ(v.y(), 55);
|
||||
EXPECT_EQ(v.z(), 55);
|
||||
|
||||
auto& data = v.data();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue