From dfee645ba5dbbb2cc234407f27328746e4dde622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Wed, 19 Aug 2015 13:59:41 +0800 Subject: [PATCH] add --- TinySTL/Test/TypeTraitsTest.cpp | 13 +++++++++++++ TinySTL/Test/TypeTraitsTest.h | 12 ++++++++++++ TinySTL/TinySTL.vcxproj | 2 ++ TinySTL/TinySTL.vcxproj.filters | 6 ++++++ TinySTL/TypeTraits.h | 15 ++++++++++++++- TinySTL/main.cpp | 2 ++ 6 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 TinySTL/Test/TypeTraitsTest.cpp create mode 100644 TinySTL/Test/TypeTraitsTest.h diff --git a/TinySTL/Test/TypeTraitsTest.cpp b/TinySTL/Test/TypeTraitsTest.cpp new file mode 100644 index 0000000..e74cbdc --- /dev/null +++ b/TinySTL/Test/TypeTraitsTest.cpp @@ -0,0 +1,13 @@ +#include "TypeTraitsTest.h" +#include + +namespace TinySTL{ + namespace TypeTraitsTest{ + void testCase1(){ + } + + void testAllCases(){ + testCase1(); + } + } +} \ No newline at end of file diff --git a/TinySTL/Test/TypeTraitsTest.h b/TinySTL/Test/TypeTraitsTest.h new file mode 100644 index 0000000..0a5ea55 --- /dev/null +++ b/TinySTL/Test/TypeTraitsTest.h @@ -0,0 +1,12 @@ +#ifndef _TYPE_TRAITS_TEST_H_ +#define _TYPE_TRAITS_TEST_H_ + +#include "../TypeTraits.h" + +namespace TinySTL{ + namespace TypeTraitsTest{ + void testAllCases(); + } +} + +#endif \ No newline at end of file diff --git a/TinySTL/TinySTL.vcxproj b/TinySTL/TinySTL.vcxproj index 5e1c381..c177dde 100644 --- a/TinySTL/TinySTL.vcxproj +++ b/TinySTL/TinySTL.vcxproj @@ -103,6 +103,7 @@ + @@ -160,6 +161,7 @@ + diff --git a/TinySTL/TinySTL.vcxproj.filters b/TinySTL/TinySTL.vcxproj.filters index 02e2c24..93af36e 100644 --- a/TinySTL/TinySTL.vcxproj.filters +++ b/TinySTL/TinySTL.vcxproj.filters @@ -111,6 +111,9 @@ Test + + Test + @@ -299,6 +302,9 @@ 头文件 + + Test + diff --git a/TinySTL/TypeTraits.h b/TinySTL/TypeTraits.h index 701ab79..4f25885 100644 --- a/TinySTL/TypeTraits.h +++ b/TinySTL/TypeTraits.h @@ -3,6 +3,19 @@ namespace TinySTL{ + namespace{ + template + struct IfThenElse; + template + struct IfThenElse < true, Ta, Tb > { + using result = Ta; + }; + template + struct IfThenElse < false, Ta, Tb > { + using result = Tb; + }; + } + struct _true_type { }; struct _false_type { }; @@ -236,6 +249,6 @@ namespace TinySTL{ typedef _true_type has_trivial_destructor; typedef _true_type is_POD_type; }; -} +} #endif \ No newline at end of file diff --git a/TinySTL/main.cpp b/TinySTL/main.cpp index df3e100..f1a9726 100644 --- a/TinySTL/main.cpp +++ b/TinySTL/main.cpp @@ -21,6 +21,7 @@ #include "Test\StringTest.h" #include "Test\SuffixArrayTest.h" #include "Test\TrieTreeTest.h" +#include "Test\TypeTraitsTest.h" #include "Test\UFSetTest.h" #include "Test\UniquePtrTest.h" #include "Test\Unordered_setTest.h" @@ -47,6 +48,7 @@ int main(){ TinySTL::StringTest::testAllCases(); TinySTL::SuffixArrayTest::testAllCases(); TinySTL::TrieTreeTest::testAllCases(); + TinySTL::TypeTraitsTest::testAllCases(); TinySTL::UFSetTest::testAllCases(); TinySTL::UniquePtrTest::testAllCases(); TinySTL::Unordered_setTest::testAllCases(); -- GitLab