Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7da4eef

Browse files
author
Dave Bartolomeo
committed
Fix subtle typing issue with std::makr_pair
1 parent 675256a commit 7da4eef

2 files changed

Lines changed: 53 additions & 18 deletions

File tree

cpp/ql/test/library-tests/dataflow/taint-tests/stl.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11

22
typedef unsigned long size_t;
33

4-
template<class T>
5-
struct remove_const { typedef T type; };
64

7-
template<class T>
8-
struct remove_const<const T> { typedef T type; };
95

10-
// `remove_const_t<T>` removes any `const` specifier from `T`
11-
template<class T>
12-
using remove_const_t = typename remove_const<T>::type;
136

14-
template<class T>
15-
struct remove_reference { typedef T type; };
167

17-
template<class T>
18-
struct remove_reference<T &> { typedef T type; };
198

20-
template<class T>
21-
struct remove_reference<T &&> { typedef T type; };
229

23-
// `remove_reference_t<T>` removes any `&` from `T`
24-
template<class T>
25-
using remove_reference_t = typename remove_reference<T>::type;
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
#include "type_traits.h"
2626

2727
namespace std
2828
{
@@ -344,8 +344,8 @@ namespace std {
344344
void swap(pair& p) /*noexcept(...)*/;
345345
};
346346

347-
template<class T1, class T2> constexpr pair<remove_reference_t<T1>, remove_reference_t<T2>> make_pair(T1&& x, T2&& y) {
348-
return pair<T1, T2>(std::forward<T1>(x), std::forward<T2>(y));
347+
template<class T1, class T2> constexpr pair<decay_t<T1>, decay_t<T2>> make_pair(T1&& x, T2&& y) {
348+
return pair<decay_t<T1>, decay_t<T2>>(std::forward<T1>(x), std::forward<T2>(y));
349349
}
350350
}
351351

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
template<class T>
2+
struct remove_const { typedef T type; };
3+
4+
template<class T>
5+
struct remove_const<const T> { typedef T type; };
6+
7+
// `remove_const_t<T>` removes any `const` specifier from `T`
8+
template<class T>
9+
using remove_const_t = typename remove_const<T>::type;
10+
11+
template<class T>
12+
struct remove_reference { typedef T type; };
13+
14+
template<class T>
15+
struct remove_reference<T &> { typedef T type; };
16+
17+
template<class T>
18+
struct remove_reference<T &&> { typedef T type; };
19+
20+
// `remove_reference_t<T>` removes any `&` from `T`
21+
template<class T>
22+
using remove_reference_t = typename remove_reference<T>::type;
23+
24+
template<class T>
25+
struct decay_impl {
26+
typedef T type;
27+
};
28+
29+
template<class T, size_t t_size>
30+
struct decay_impl<T[t_size]> {
31+
typedef T* type;
32+
};
33+
34+
template<class T>
35+
using decay_t = typename decay_impl<remove_reference_t<T>>::type;

0 commit comments

Comments
 (0)