Skip to content

Commit fcaa42b

Browse files
committed
Merge branch 'master' of https://github.com/chronolaw/cpp_study
2 parents 49a6d26 + ab5db0c commit fcaa42b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

section2/auto.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
// g++ auto.cpp -std=c++14 -o a.out;./a.out
55
// g++ auto.cpp -std=c++14 -I../common -o a.out;./a.out
66

7+
#include <cassert>
8+
79
#include <iostream>
810
#include <string>
911
#include <vector>
1012
#include <set>
1113
#include <map>
1214

15+
#include <type_traits>
16+
1317
#include <signal.h>
1418

1519
void case1()
@@ -97,6 +101,10 @@ void case6()
97101
decltype(auto) x1 = (x);
98102
decltype(auto) x2 = &x;
99103
decltype(auto) x3 = x1;
104+
105+
assert(std::is_lvalue_reference<decltype(x1)>::value);
106+
assert(std::is_pointer<decltype(x2)>::value);
107+
assert(std::is_lvalue_reference<decltype(x3)>::value);
100108
}
101109

102110
auto get_a_set()

section4/msgpack.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ void case3()
9797
msgpack::sbuffer sbuf;
9898
msgpack::pack(sbuf, book1);
9999

100-
auto obj = msgpack::unpack(sbuf.data(), sbuf.size()).get();
100+
// may cause std::bad_cast error
101+
//auto obj = msgpack::unpack(sbuf.data(), sbuf.size()).get();
102+
103+
auto handle = msgpack::unpack(sbuf.data(), sbuf.size());
104+
auto obj = handle.get();
101105

102106
Book book2;
103107
obj.convert(book2);

0 commit comments

Comments
 (0)