Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
1dcabbf8
Commit
1dcabbf8
authored
Jun 04, 2017
by
Kenton Varda
Committed by
GitHub
Jun 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #489 from harrishancock/fix-msvc-sfinae-error
Fix MSVC build error when using List<T> with generic T
parents
9b7be551
bd78705c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
12 deletions
+19
-12
common.h
c++/src/capnp/common.h
+9
-5
capnpc-c++.c++
c++/src/capnp/compiler/capnpc-c++.c++
+7
-7
test.capnp
c++/src/capnp/test.capnp
+3
-0
No files found.
c++/src/capnp/common.h
View file @
1dcabbf8
...
@@ -161,15 +161,19 @@ inline constexpr Kind kind() {
...
@@ -161,15 +161,19 @@ inline constexpr Kind kind() {
return
k
;
return
k
;
}
}
#if
CAPNP_LITE
#if
_MSC_VER
#define CAPNP_KIND(T) ::capnp::_::Kind_<T>::kind
#define CAPNP_KIND(T) ::capnp::_::Kind_<T>::kind
// Avoid constexpr methods in
lite mode (MSVC is bad at constexpr
).
// Avoid constexpr methods in
MSVC (it remains buggy in many situations
).
#else //
CAPNP_LITE
#else //
_MSC_VER
#define CAPNP_KIND(T) ::capnp::kind<T>()
#define CAPNP_KIND(T) ::capnp::kind<T>()
// Use this macro rather than kind<T>() in any code which must work in lite mode.
// Use this macro rather than kind<T>() in any code which must work in MSVC.
#endif // _MSC_VER, else
#if !CAPNP_LITE
template
<
typename
T
,
Kind
k
=
kind
<
T
>
()
>
template
<
typename
T
,
Kind
k
=
kind
<
T
>
()
>
inline
constexpr
Style
style
()
{
inline
constexpr
Style
style
()
{
...
@@ -178,7 +182,7 @@ inline constexpr Style style() {
...
@@ -178,7 +182,7 @@ inline constexpr Style style() {
:
k
==
Kind
::
INTERFACE
?
Style
::
CAPABILITY
:
Style
::
POINTER
;
:
k
==
Kind
::
INTERFACE
?
Style
::
CAPABILITY
:
Style
::
POINTER
;
}
}
#endif //
CAPNP_LITE, else
#endif //
!CAPNP_LITE
template
<
typename
T
,
Kind
k
=
CAPNP_KIND
(
T
)
>
template
<
typename
T
,
Kind
k
=
CAPNP_KIND
(
T
)
>
struct
List
;
struct
List
;
...
...
c++/src/capnp/compiler/capnpc-c++.c++
View file @
1dcabbf8
...
@@ -494,7 +494,7 @@ private:
...
@@ -494,7 +494,7 @@ private:
case
schema
:
:
Type
::
AnyPointer
::
Unconstrained
::
LIST
:
case
schema
:
:
Type
::
AnyPointer
::
Unconstrained
::
LIST
:
return
CppTypeName
::
makePrimitive
(
" ::capnp::AnyList"
);
return
CppTypeName
::
makePrimitive
(
" ::capnp::AnyList"
);
case
schema
:
:
Type
::
AnyPointer
::
Unconstrained
::
CAPABILITY
:
case
schema
:
:
Type
::
AnyPointer
::
Unconstrained
::
CAPABILITY
:
hasInterfaces
=
true
;
// Probably need to #inc
ul
de <capnp/capability.h>.
hasInterfaces
=
true
;
// Probably need to #inc
lu
de <capnp/capability.h>.
return
CppTypeName
::
makePrimitive
(
" ::capnp::Capability"
);
return
CppTypeName
::
makePrimitive
(
" ::capnp::Capability"
);
}
}
KJ_UNREACHABLE
;
KJ_UNREACHABLE
;
...
@@ -682,12 +682,12 @@ private:
...
@@ -682,12 +682,12 @@ private:
kj
::
StringTree
dependencies
;
kj
::
StringTree
dependencies
;
size_t
dependencyCount
;
size_t
dependencyCount
;
// TODO(msvc): `dependencyCount` is the number of individual dependency definitions in
// TODO(msvc): `dependencyCount` is the number of individual dependency definitions in
// `dependencies`. It's a hack to allow makeGenericDefinitions to hard-code the size of the
//
`dependencies`. It's a hack to allow makeGenericDefinitions to hard-code the size of the
// `_capnpPrivate::brandDependencies` array into the definition of
//
`_capnpPrivate::brandDependencies` array into the definition of
//
`_capnpPrivate::specificBrand::dependencyCount`. This is necessary because MSVC cannot deduce
//
`_capnpPrivate::specificBrand::dependencyCount`. This is necessary because MSVC cannot
//
the size of `brandDependencies` if it is nested under a class template. It's probably thi
s
//
deduce the size of `brandDependencies` if it is nested under a class template. It'
s
// demoralizingly deferred bug:
//
probably this
demoralizingly deferred bug:
// https://connect.microsoft.com/VisualStudio/feedback/details/759407/can-not-get-size-of-static-array-defined-in-class-template
//
https://connect.microsoft.com/VisualStudio/feedback/details/759407/can-not-get-size-of-static-array-defined-in-class-template
};
};
BrandInitializerText
makeBrandInitializers
(
BrandInitializerText
makeBrandInitializers
(
...
...
c++/src/capnp/test.capnp
View file @
1dcabbf8
...
@@ -537,6 +537,9 @@ struct TestGenerics(Foo, Bar) {
...
@@ -537,6 +537,9 @@ struct TestGenerics(Foo, Bar) {
}
}
}
}
list @4 :List(Inner);
# At one time this failed to compile with MSVC due to poor expression SFINAE support.
struct Inner {
struct Inner {
foo @0 :Foo;
foo @0 :Foo;
bar @1 :Bar;
bar @1 :Bar;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment