Skip to content

Commit f0632bf

Browse files
* fixed strict conformance issue in vs2019 (#31)
1 parent db01dff commit f0632bf

File tree

12 files changed

+317
-268
lines changed

12 files changed

+317
-268
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Header-only heriarchical FSM framework in C++11, with fully statically-defined s
2121

2222
## See Also
2323

24-
- **[FFSM2](https://flat.hfsm.dev)**: High-Performance **Flat** Finite State Machine Framework
24+
- **[FFSM2](https://flat.hfsm.dev)**: High-Performance **Flat** Finite State Machine
2525

2626
---
2727

@@ -64,8 +64,8 @@ Header-only heriarchical FSM framework in C++11, with fully statically-defined s
6464

6565
## Receive Updates
6666

67-
- Blog: [gresyk.dev](https://gresyk.dev)
68-
- Twitter: [@andrew_gresyk](https://www.twitter.com/andrew_gresyk)
67+
- Blog: **[gresyk.dev](https://gresyk.dev)**
68+
- Twitter: **[@andrew_gresyk](https://www.twitter.com/andrew_gresyk)**
6969

7070
---
7171

appveyor.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "{build}"
22

33
image:
4-
- Visual Studio 2017
4+
- Visual Studio 2019
55

66
configuration:
77
- Debug
@@ -12,9 +12,9 @@ platform:
1212
- x64
1313

1414
build:
15-
project: projects\visual-studio\hfsm2-15-vs.sln
15+
project: projects\visual-studio\hfsm2-16-vs.sln
1616
parallel: true
1717
verbosity: minimal
1818

1919
test_script:
20-
- cmd: binaries-%PLATFORM%\test-15-%CONFIGURATION%-%PLATFORM%.exe
20+
- cmd: binaries-%PLATFORM%\test-16-%CONFIGURATION%-%PLATFORM%.exe

include/hfsm2/detail/root/plan_data.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace detail {
88
#pragma pack(push, 2)
99

1010
struct TaskBase {
11+
HFSM2_INLINE TaskBase() {}
12+
1113
HFSM2_INLINE TaskBase(const StateID origin_,
1214
const StateID destination_,
1315
const TransitionType type_)
@@ -18,7 +20,7 @@ struct TaskBase {
1820

1921
StateID origin = INVALID_STATE_ID;
2022
StateID destination = INVALID_STATE_ID;
21-
TransitionType type;
23+
TransitionType type = TransitionType::COUNT;
2224
};
2325

2426
//------------------------------------------------------------------------------
@@ -34,6 +36,12 @@ struct TaskT
3436

3537
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3638

39+
HFSM2_INLINE TaskT() {
40+
new (&storage) Payload{};
41+
}
42+
43+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
44+
3745
HFSM2_INLINE TaskT(const StateID origin,
3846
const StateID destination,
3947
const TransitionType type,

include/hfsm2/detail/shared/list.hpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,14 @@ class List {
1717

1818
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1919

20-
struct Links {
20+
struct Cell {
21+
Item item;
2122
Index prev;
2223
Index next;
2324
};
2425

2526
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2627

27-
union Cell {
28-
Item item;
29-
Links links;
30-
31-
HFSM2_INLINE Cell()
32-
: links{}
33-
{}
34-
};
35-
36-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
37-
3828
public:
3929
template <typename... TArgs>
4030
Index emplace(TArgs... args);

include/hfsm2/detail/shared/list.inl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ List<T, NC>::emplace(TA... args) {
1717

1818
if (_vacantHead != _vacantTail) {
1919
// recycle
20-
HFSM2_ASSERT(cell.links.prev == INVALID);
21-
HFSM2_ASSERT(cell.links.next != INVALID);
20+
HFSM2_ASSERT(cell.prev == INVALID);
21+
HFSM2_ASSERT(cell.next != INVALID);
2222

23-
_vacantHead = cell.links.next;
23+
_vacantHead = cell.next;
2424

2525
auto& head = _cells[_vacantHead];
26-
HFSM2_ASSERT(head.links.prev == index);
27-
head.links.prev = INVALID;
26+
HFSM2_ASSERT(head.prev == index);
27+
head.prev = INVALID;
2828
} else if (_last < CAPACITY - 1) {
2929
// grow
3030
++_last;
3131
_vacantHead = _last;
3232
_vacantTail = _last;
3333

3434
auto& vacant = _cells[_vacantHead];
35-
vacant.links.prev = INVALID;
36-
vacant.links.next = INVALID;
35+
vacant.prev = INVALID;
36+
vacant.next = INVALID;
3737
} else {
3838
HFSM2_ASSERT(_count == CAPACITY);
3939

@@ -70,11 +70,11 @@ List<T, NC>::remove(const Index i) {
7070
HFSM2_ASSERT(_vacantHead < CAPACITY);
7171
HFSM2_ASSERT(_vacantTail < CAPACITY);
7272

73-
fresh.links.prev = INVALID;
74-
fresh.links.next = _vacantHead;
73+
fresh.prev = INVALID;
74+
fresh.next = _vacantHead;
7575

7676
auto& head = _cells[_vacantHead];
77-
head.links.prev = i;
77+
head.prev = i;
7878

7979
_vacantHead = i;
8080
} else {
@@ -83,8 +83,8 @@ List<T, NC>::remove(const Index i) {
8383
HFSM2_ASSERT(_vacantHead == INVALID);
8484
HFSM2_ASSERT(_vacantTail == INVALID);
8585

86-
fresh.links.prev = INVALID;
87-
fresh.links.next = INVALID;
86+
fresh.prev = INVALID;
87+
fresh.next = INVALID;
8888

8989
_vacantHead = i;
9090
_vacantTail = i;
@@ -126,8 +126,8 @@ List<T, NC>::verifyStructure(const Index occupied) const {
126126
HFSM2_ASSERT(_vacantHead < CAPACITY);
127127
HFSM2_ASSERT(_vacantTail < CAPACITY);
128128

129-
HFSM2_ASSERT(_cells[_vacantHead].links.prev == INVALID);
130-
HFSM2_ASSERT(_cells[_vacantTail].links.next == INVALID);
129+
HFSM2_ASSERT(_cells[_vacantHead].prev == INVALID);
130+
HFSM2_ASSERT(_cells[_vacantTail].next == INVALID);
131131

132132
auto emptyCount = 1;
133133

@@ -136,12 +136,12 @@ List<T, NC>::verifyStructure(const Index occupied) const {
136136

137137
const auto& current = _cells[c];
138138

139-
const auto f = current.links.next;
139+
const auto f = current.next;
140140
if (f != INVALID) {
141141
// next
142142
const auto& following = _cells[f];
143143

144-
HFSM2_ASSERT(following.links.prev == c);
144+
HFSM2_ASSERT(following.prev == c);
145145

146146
c = f;
147147
continue;

include/hfsm2/machine.hpp

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,24 +1451,14 @@ class List {
14511451

14521452
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14531453

1454-
struct Links {
1454+
struct Cell {
1455+
Item item;
14551456
Index prev;
14561457
Index next;
14571458
};
14581459

14591460
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14601461

1461-
union Cell {
1462-
Item item;
1463-
Links links;
1464-
1465-
HFSM2_INLINE Cell()
1466-
: links{}
1467-
{}
1468-
};
1469-
1470-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1471-
14721462
public:
14731463
template <typename... TArgs>
14741464
Index emplace(TArgs... args);
@@ -1520,23 +1510,23 @@ List<T, NC>::emplace(TA... args) {
15201510

15211511
if (_vacantHead != _vacantTail) {
15221512
// recycle
1523-
HFSM2_ASSERT(cell.links.prev == INVALID);
1524-
HFSM2_ASSERT(cell.links.next != INVALID);
1513+
HFSM2_ASSERT(cell.prev == INVALID);
1514+
HFSM2_ASSERT(cell.next != INVALID);
15251515

1526-
_vacantHead = cell.links.next;
1516+
_vacantHead = cell.next;
15271517

15281518
auto& head = _cells[_vacantHead];
1529-
HFSM2_ASSERT(head.links.prev == index);
1530-
head.links.prev = INVALID;
1519+
HFSM2_ASSERT(head.prev == index);
1520+
head.prev = INVALID;
15311521
} else if (_last < CAPACITY - 1) {
15321522
// grow
15331523
++_last;
15341524
_vacantHead = _last;
15351525
_vacantTail = _last;
15361526

15371527
auto& vacant = _cells[_vacantHead];
1538-
vacant.links.prev = INVALID;
1539-
vacant.links.next = INVALID;
1528+
vacant.prev = INVALID;
1529+
vacant.next = INVALID;
15401530
} else {
15411531
HFSM2_ASSERT(_count == CAPACITY);
15421532

@@ -1573,11 +1563,11 @@ List<T, NC>::remove(const Index i) {
15731563
HFSM2_ASSERT(_vacantHead < CAPACITY);
15741564
HFSM2_ASSERT(_vacantTail < CAPACITY);
15751565

1576-
fresh.links.prev = INVALID;
1577-
fresh.links.next = _vacantHead;
1566+
fresh.prev = INVALID;
1567+
fresh.next = _vacantHead;
15781568

15791569
auto& head = _cells[_vacantHead];
1580-
head.links.prev = i;
1570+
head.prev = i;
15811571

15821572
_vacantHead = i;
15831573
} else {
@@ -1586,8 +1576,8 @@ List<T, NC>::remove(const Index i) {
15861576
HFSM2_ASSERT(_vacantHead == INVALID);
15871577
HFSM2_ASSERT(_vacantTail == INVALID);
15881578

1589-
fresh.links.prev = INVALID;
1590-
fresh.links.next = INVALID;
1579+
fresh.prev = INVALID;
1580+
fresh.next = INVALID;
15911581

15921582
_vacantHead = i;
15931583
_vacantTail = i;
@@ -1629,8 +1619,8 @@ List<T, NC>::verifyStructure(const Index occupied) const {
16291619
HFSM2_ASSERT(_vacantHead < CAPACITY);
16301620
HFSM2_ASSERT(_vacantTail < CAPACITY);
16311621

1632-
HFSM2_ASSERT(_cells[_vacantHead].links.prev == INVALID);
1633-
HFSM2_ASSERT(_cells[_vacantTail].links.next == INVALID);
1622+
HFSM2_ASSERT(_cells[_vacantHead].prev == INVALID);
1623+
HFSM2_ASSERT(_cells[_vacantTail].next == INVALID);
16341624

16351625
auto emptyCount = 1;
16361626

@@ -1639,12 +1629,12 @@ List<T, NC>::verifyStructure(const Index occupied) const {
16391629

16401630
const auto& current = _cells[c];
16411631

1642-
const auto f = current.links.next;
1632+
const auto f = current.next;
16431633
if (f != INVALID) {
16441634
// next
16451635
const auto& following = _cells[f];
16461636

1647-
HFSM2_ASSERT(following.links.prev == c);
1637+
HFSM2_ASSERT(following.prev == c);
16481638

16491639
c = f;
16501640
continue;
@@ -2880,6 +2870,8 @@ namespace detail {
28802870
#pragma pack(push, 2)
28812871

28822872
struct TaskBase {
2873+
HFSM2_INLINE TaskBase() {}
2874+
28832875
HFSM2_INLINE TaskBase(const StateID origin_,
28842876
const StateID destination_,
28852877
const TransitionType type_)
@@ -2890,7 +2882,7 @@ struct TaskBase {
28902882

28912883
StateID origin = INVALID_STATE_ID;
28922884
StateID destination = INVALID_STATE_ID;
2893-
TransitionType type;
2885+
TransitionType type = TransitionType::COUNT;
28942886
};
28952887

28962888
//------------------------------------------------------------------------------
@@ -2906,6 +2898,12 @@ struct TaskT
29062898

29072899
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
29082900

2901+
HFSM2_INLINE TaskT() {
2902+
new (&storage) Payload{};
2903+
}
2904+
2905+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2906+
29092907
HFSM2_INLINE TaskT(const StateID origin,
29102908
const StateID destination,
29112909
const TransitionType type,

0 commit comments

Comments
 (0)