Skip to content

Commit

Permalink
Generate is_move_constructible<T>: std::false_type to tell pybind11…
Browse files Browse the repository at this point in the history
… that `T` is not movable.

This is to fix test failures like https://fusion2.corp.google.com/invocations;page_size=25;offset=25/ae1d8f43-43e1-4bbe-8c99-156ea3256d55/targets (failed).

PiperOrigin-RevId: 526123390
  • Loading branch information
wangxf authored and wangxf123456 committed May 18, 2023
1 parent 9394cd6 commit e6ff775
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions clif/pybind11/gen_type_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,24 @@ class ClassType(BaseType):

py_bases: Set[str]

def generate_type_trait(self, type_trait: str) -> Generator[str, None, None]:
yield ''
yield 'namespace pybind11 {'
yield 'namespace detail {'
yield ''
yield 'template <>'
yield f'struct {type_trait}<{self.cpp_name}>: std::false_type {{}};'
yield ''
yield '} // namespace detail'
yield '} // namespace pybind11'
yield ''

def generate_type_caster(self) -> Generator[str, None, None]:
yield f'PYBIND11_SMART_HOLDER_TYPE_CASTERS({self.cpp_name})'
if not self.cpp_copyable:
yield ''
yield 'namespace pybind11 {'
yield 'namespace detail {'
yield ''
yield 'template <>'
yield (f'struct is_copy_constructible<{self.cpp_name}>: '
'std::false_type {};')
yield ''
yield '} // namespace detail'
yield '} // namespace pybind11'
yield ''
yield from self.generate_type_trait('is_copy_constructible')
if not self.cpp_movable:
yield from self.generate_type_trait('is_move_constructible')

def generate_header(self) -> Generator[str, None, None]:
yield ''
Expand Down

0 comments on commit e6ff775

Please sign in to comment.