Ticket #14346: 16040-reproducer.cpp

File 16040-reproducer.cpp, 838 bytes (added by KapiX, 3 years ago)

Reproducer based on #16040

Line 
1#include <algorithm>
2#include <string>
3#include <vector>
4
5struct Value {
6 int node;
7};
8
9template<typename T>
10struct NodeComparator {
11 bool operator()(const T& a, const T& b) {
12 return a < b;
13 }
14};
15
16struct List : public std::vector<Value> {
17 using ValueType = Value;
18};
19
20struct DumpContext {};
21
22namespace JSC {
23namespace DFG {
24template<typename T>
25std::string nodeValuePairListDump(const T& nodeValuePairList, DumpContext* context = 0)
26{
27 using V = typename T::ValueType;
28 T sortedList = nodeValuePairList;
29 std::sort(sortedList.begin(), sortedList.end(), [](const V& a, const V& b) {
30 return NodeComparator<int>()(a.node, b.node);
31 });
32 return "";
33}
34}
35}
36
37int main(int argc, char** argv)
38{
39 List l;
40 l.push_back(Value{.node = 2});
41 l.push_back(Value{.node = 1});
42 JSC::DFG::nodeValuePairListDump<List>(l);
43 return 0;
44}