Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
fbe82bf9
Commit
fbe82bf9
authored
Jul 28, 2015
by
Wenzel Jakob
Browse files
code size reduction
parent
43398a85
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
include/pybind/typeid.h
include/pybind/typeid.h
+14
-10
No files found.
include/pybind/typeid.h
View file @
fbe82bf9
...
@@ -26,23 +26,27 @@ inline void erase_all(std::string &string, const std::string &search) {
...
@@ -26,23 +26,27 @@ inline void erase_all(std::string &string, const std::string &search) {
string
.
erase
(
pos
,
search
.
length
());
string
.
erase
(
pos
,
search
.
length
());
}
}
}
}
NAMESPACE_END
(
detail
)
/// Return a string representation of a C++ type
inline
void
clean_type_id
(
std
::
string
&
name
)
{
template
<
typename
T
>
static
std
::
string
type_id
()
{
#if defined(__GNUG__)
std
::
string
name
(
typeid
(
T
).
name
());
int
status
=
0
;
#if defined(__GNUG__)
std
::
unique_ptr
<
char
,
void
(
*
)(
void
*
)
>
res
{
int
status
=
0
;
abi
::
__cxa_demangle
(
name
.
c_str
(),
nullptr
,
nullptr
,
&
status
),
std
::
free
};
std
::
unique_ptr
<
char
,
void
(
*
)(
void
*
)
>
res
{
if
(
status
==
0
)
abi
::
__cxa_demangle
(
name
.
c_str
(),
nullptr
,
nullptr
,
&
status
),
std
::
free
};
name
=
res
.
get
();
if
(
status
==
0
)
name
=
res
.
get
();
#else
#else
detail
::
erase_all
(
name
,
"class "
);
detail
::
erase_all
(
name
,
"class "
);
detail
::
erase_all
(
name
,
"struct "
);
detail
::
erase_all
(
name
,
"struct "
);
detail
::
erase_all
(
name
,
"enum "
);
detail
::
erase_all
(
name
,
"enum "
);
#endif
#endif
detail
::
erase_all
(
name
,
"pybind::"
);
detail
::
erase_all
(
name
,
"pybind::"
);
}
NAMESPACE_END
(
detail
)
/// Return a string representation of a C++ type
template
<
typename
T
>
static
std
::
string
type_id
()
{
std
::
string
name
(
typeid
(
T
).
name
());
detail
::
clean_type_id
(
name
);
return
name
;
return
name
;
}
}
...
...
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