static_cast assignments by default.
This can be disabled by defining VWR_WITH_UNCASTED_ASSIGNMENT.
This commit is contained in:
parent
33bc1e73da
commit
83418105e3
3 changed files with 24 additions and 3 deletions
|
@ -176,7 +176,11 @@ namespace vwr {
|
|||
template <typename V1, typename V2, size_type D>
|
||||
inline Vec<V1>& assign (Vec<V1, D>& parLeft, const Vec<V2, D>& parRight) {
|
||||
for (size_type z = 0; z < D; ++z) {
|
||||
#if defined(VWR_WITH_UNCASTED_ASSIGNMENT)
|
||||
parLeft[z] = parRight[z];
|
||||
#else
|
||||
parLeft[z] = static_cast<typename Vec<V1>::scalar_type>(parRight[z]);
|
||||
#endif
|
||||
}
|
||||
return parLeft;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)
|
|||
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -std=c++11")
|
||||
|
||||
add_subdirectory(gtest-1.7.0)
|
||||
set(GTEST_MAIN_CPP "${CMAKE_SOURCE_DIR}/gtest-1.7.0/src/gtest_main.cc")
|
||||
set(UNITTEST_DATA_DIR "${CMAKE_SOURCE_DIR}/../data")
|
||||
|
@ -12,6 +9,17 @@ set(UNITTEST_DATA_DIR "${CMAKE_SOURCE_DIR}/../data")
|
|||
include_directories(SYSTEM
|
||||
gtest-1.7.0/include
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -std=c++11")
|
||||
|
||||
add_definitions(
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
-Wconversion
|
||||
)
|
||||
|
||||
include_directories(../include)
|
||||
add_subdirectory(unit)
|
||||
add_subdirectory(unit_noconv)
|
||||
|
|
|
@ -53,3 +53,12 @@ TEST(vwr, conversion) {
|
|||
test_tvec3(p3.cast<tvec3>(), p3.x(), p3.y(), p3.z());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(vwr, cast) {
|
||||
using namespace vwr;
|
||||
|
||||
svec2 s(10.0f);
|
||||
ivec2 i = static_cast<ivec2>(s);
|
||||
EXPECT_EQ(i.x(), 10);
|
||||
EXPECT_EQ(i.y(), 10);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue