Skip to content

Commit cf2e171

Browse files
committed
Initial commit
0 parents  commit cf2e171

File tree

12 files changed

+252
-0
lines changed

12 files changed

+252
-0
lines changed

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# wio
2+
.wio/
3+
4+
# Mac OS
5+
.DS_Store
6+
.DS_Store?
7+
.AppleDouble
8+
.LSOverride
9+
._*
10+
.Spotlight-V100
11+
.Trashes
12+
ehthumbs.db
13+
Thumbs.db
14+
15+
# Windows
16+
Thumbs.db
17+
ehthumbs.db
18+
ehthumbs_vista.db
19+
[Dd]esktop.ini
20+
21+
22+
# C++ Prerequisites
23+
*.d
24+
25+
# C++ Compiled Object files
26+
*.slo
27+
*.lo
28+
*.o
29+
*.obj
30+
31+
# C++ Precompiled Headers
32+
*.gch
33+
*.pch
34+
35+
# C++ Compiled Dynamic libraries
36+
*.so
37+
*.dylib
38+
*.dll
39+
40+
.vscode/
41+
.idea/
42+
cmake-build-debug/

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.1.0)
2+
project(wlib-tmp)
3+
4+
file(GLOB_RECURSE WLIB_TMP_FILES
5+
include/*
6+
include/wlib/*.h
7+
)
8+
9+
add_executable(tests ${WLIB_TMP_FILES} tests/main.cpp)
10+
target_include_directories(tests PRIVATE include)

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# wlib-tmp
2+
3+
This is a wio AVR package. It is compatible with:
4+
* Frameworks: cosa
5+
* Boards: all
6+
7+
To include this package as dependency
8+
```bash
9+
wio pac add wlib-tmp@latest
10+
```

include/wlib/tmp/Condition.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#ifndef __WLIB_TMP_CONDITION_H__
2+
#define __WLIB_TMP_CONDITION_H__
3+
4+
#include <wlib/tmp/IntegralConstant.h>
5+
6+
namespace wlp {
7+
8+
// conditional
9+
template<bool, typename, typename> struct conditional;
10+
template<bool condition, typename if_true, typename if_false>
11+
struct conditional { typedef if_true type; };
12+
template<typename if_true, typename if_false>
13+
struct conditional<false, if_true, if_false> { typedef if_false type; };
14+
15+
// or_
16+
template<typename...> struct or_;
17+
template<> struct or_<> : public false_type {};
18+
template<typename Q1> struct or_<Q1> : public Q1 {};
19+
template<typename Q1, typename Q2> struct or_<Q1, Q2> : public conditional<Q1::value, Q1, Q2>::type {};
20+
21+
template<typename Q1, typename Q2, typename Q3, typename... Qn>
22+
struct or_<Q1, Q2, Q3, Qn...> : public conditional<Q1::value, Q1, or_<Q2, Q3, Qn...>>::type {};
23+
24+
// and_
25+
template<typename...> struct and_;
26+
template<> struct and_<> : public true_type {};
27+
template<typename Q1> struct and_<Q1> : public Q1 {};
28+
template<typename Q1, typename Q2> struct and_<Q1, Q2> : public conditional<Q1::value, Q2, Q1>::type {};
29+
30+
template<typename Q1, typename Q2, typename Q3, typename... Qn>
31+
struct and_<Q1, Q2, Q3, Qn...>: public conditional<Q1::value, and_<Q2, Q3, Qn...>, Q1>::type {};
32+
33+
// not_
34+
template<typename T> struct not_ : public integral_constant<bool, !T::value> {};
35+
36+
}
37+
38+
#endif

include/wlib/tmp/IntegralConstant.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef __WLIB_TMP_INTEGRALCONSTANT_H__
2+
#define __WLIB_TMP_INTEGRALCONSTANT_H__
3+
4+
namespace wlp {
5+
6+
// integral_constant
7+
template<typename T, T t>
8+
struct integral_constant {
9+
static constexpr T value = t;
10+
typedef T value_type;
11+
typedef integral_constant<T, t> type;
12+
};
13+
typedef integral_constant<bool, true> true_type;
14+
typedef integral_constant<bool, false> false_type;
15+
16+
}
17+
18+
#endif

include/wlib/tmp/NullptrType.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef __WLIB_TMP_NULLPTRTYPE_H__
2+
#define __WLIB_TMP_NULLPTRTYPE_H__
3+
4+
namespace wlp {
5+
6+
// nullptr_t
7+
typedef decltype(nullptr) nullptr_t;
8+
9+
}
10+
11+
#endif

include/wlib/tmp/TypeTraits.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#ifndef __WLIB_TMP_TYPETRAITS_H__
2+
#define __WLIB_TMP_TYPETRAITS_H__
3+
4+
#include <wlib/tmp/IntegralConstant.h>
5+
#include <wlib/tmp/Condition.h>
6+
7+
namespace wlp {
8+
9+
// remove const and volatile
10+
template<typename T> struct remove_const { typedef T type; };
11+
template<typename T> struct remove_const<T const> { typedef T type; };
12+
template<typename T> struct remove_volatile { typedef T type; };
13+
template<typename T> struct remove_volatile<T volatile> { typedef T type; };
14+
template<typename T> struct remove_cv
15+
{ typedef typename remove_const<typename remove_volatile<T>::type>::type type; };
16+
17+
// is_void
18+
namespace det {
19+
template<typename> struct is_void_helper : public false_type {};
20+
template<> struct is_void_helper<void> : public true_type {};
21+
}
22+
template<typename T> struct is_void :
23+
public det::is_void_helper<typename remove_const<T>::type>::type {};
24+
25+
// is_reference
26+
template<typename> struct is_lvalue_reference : public false_type {};
27+
template<typename T> struct is_lvalue_reference<T &> : public true_type {};
28+
template<typename> struct is_rvalue_reference : public false_type {};
29+
template<typename T> struct is_rvalue_reference<T &&> : public true_type {};
30+
31+
template<typename T> struct is_reference :
32+
public or_<is_lvalue_reference<T>, is_rvalue_reference<T>>::type {};
33+
34+
// remove_pointer
35+
namespace det {
36+
template<typename T, typename> struct remove_pointer_helper { typedef T type; };
37+
template<typename T, typename U> struct remove_pointer_helper<T, U *> { typedef U type; };
38+
}
39+
template<typename T> struct remove_pointer :
40+
public det::remove_pointer_helper<T, typename remove_cv<T>::type> {};
41+
42+
// remove_reference
43+
template<typename T> struct remove_reference { typedef T type; };
44+
template<typename T> struct remove_reference<T &> { typedef T type; };
45+
template<typename T> struct remove_reference<T &&> { typedef T type; };
46+
47+
// remove_extent
48+
template<typename T> struct remove_extent { typedef T type; };
49+
template<typename T> struct remove_extent<T[]> { typedef T type; };
50+
template<typename T, size_t sz> struct remove_extent<T[sz]> { typedef T type; };
51+
52+
// is_array, is_sized_array, is_unsized_array
53+
template<typename> struct is_array : public false_type {};
54+
template<typename T> struct is_array<T[]> : public true_type {};
55+
template<typename T, size_t sz> struct is_array<T[sz]> : public true_type {};
56+
template<typename> struct is_sized_array : public false_type {};
57+
template<typename T> struct is_sized_array<T[]> : public false_type {};
58+
template<typename T, size_t sz> struct is_sized_array<T[sz]> : public true_type {};
59+
template<typename> struct is_unsized_array : public false_type {};
60+
template<typename T> struct is_unsized_array<T[]> : public true_type {};
61+
template<typename T, size_t sz> struct is_unsized_array<T[sz]> : public false_type {};
62+
63+
// get_array_size
64+
template<typename> struct get_array_size {};
65+
template<typename T, size_t sz> struct get_array_size<T[sz]> :
66+
public integral_constant<size_t, sz>::type {};
67+
68+
// is_object
69+
70+
// is_referenceable
71+
72+
// add_pointer
73+
74+
}
75+
76+
#endif

include/wlib/tmp/Utility.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef __WLIB_TMP_UTILITY_H__
2+
#define __WLIB_TMP_UTILITY_H__
3+
4+
namespace wlp {
5+
6+
}
7+
8+
#endif

include/wlib/type_traits

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef __WLIB_TMP_TYPETRAITS__
2+
#define __WLIB_TMP_TYPETRAITS__
3+
4+
#include <wlib/tmp/TypeTraits.h>
5+
6+
#endif

include/wlib/utility

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef __WLIB_TMP_UTILITY__
2+
#define __WLIB_TMP_UTILITY__
3+
4+
#include <wlib/tmp/Utility.h>
5+
6+
#endif

0 commit comments

Comments
 (0)