Skip to content

Commit 24ec090

Browse files
authored
Merge pull request #4085 from gateway240/alex/vs-17.14
Move BoolLike outside of template class for VS 17.14 linker
2 parents e1d54f9 + 351d52a commit 24ec090

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This is not a comprehensive list of changes but rather a hand-curated collection
88

99
v4.6
1010
=====
11+
- Move BoolLike class outside of template Array class for the `VS 17.14` linker (#4081)
1112

1213

1314
v4.5.2

OpenSim/Common/Array.h

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@
4444

4545
namespace OpenSim {
4646

47+
// Not intended for end users => private
48+
namespace detail {
49+
// backwards-compat hack: the original implementation allows for references
50+
// to booleans, which won't work if using std::vector<bool> specialization
51+
// Moved outside the template class to ensure linking works properly in VS 17.14
52+
// See issue (#4081) for details.
53+
class BoolLike final {
54+
public:
55+
BoolLike(bool value_) : value{value_} {}
56+
operator bool& () { return value; }
57+
operator const bool& () const { return value; }
58+
private:
59+
bool value;
60+
};
61+
}
62+
4763
/**
4864
* A class for storing an array of values of type T. The capacity of the class
4965
* grows as needed. To use this template for a class of type T, class T should
@@ -575,19 +591,9 @@ class Array {
575591
private:
576592
T _defaultValue;
577593

578-
// backwards-compat hack: the original implementation allows for references
579-
// to booleans, which won't work if using std::vector<bool> specialization
580-
class BoolLike final {
581-
public:
582-
BoolLike(bool value_) : value{value_} {}
583-
operator bool& () { return value; }
584-
operator const bool& () const { return value; }
585-
private:
586-
bool value;
587-
};
588594
using storage = std::conditional_t<
589595
std::is_same<T, bool>::value,
590-
std::vector<BoolLike>,
596+
std::vector<detail::BoolLike>,
591597
std::vector<T>
592598
>;
593599

0 commit comments

Comments
 (0)