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
OpenDAS
dlib
Commits
7257589a
Commit
7257589a
authored
May 28, 2011
by
Davis King
Browse files
Moved DLIB_ASSERT_HAS_STANDARD_LAYOUT into assert.h.
parent
3b9fbda0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
dlib/algs.h
dlib/algs.h
+0
-19
dlib/assert.h
dlib/assert.h
+19
-0
No files found.
dlib/algs.h
View file @
7257589a
...
@@ -931,25 +931,6 @@ namespace dlib
...
@@ -931,25 +931,6 @@ namespace dlib
void
*
const
data
;
void
*
const
data
;
};
};
// ----------------------------------------------------------------------------------------
/*A DLIB_ASSERT_HAS_STANDARD_LAYOUT
This macro is meant to cause a compiler error if a type doesn't have a simple
memory layout (like a C struct). In particular, types with simple layouts are
ones which can be copied via memcpy().
This was called a POD type in C++03 and in C++0x we are looking to check if
it is a "standard layout type". Once we can use C++0x we can change this macro
to something that uses the std::is_standard_layout type_traits class.
See: http://www2.research.att.com/~bs/C++0xFAQ.html#PODs
*/
// Use the fact that in C++03 you can't put non-PODs into a union.
#define DLIB_ASSERT_HAS_STANDARD_LAYOUT(type) \
union BOOST_JOIN(DAHSL_,__LINE__) { type TYPE_NOT_STANDARD_LAYOUT; }; \
typedef char BOOST_JOIN(DAHSL2_,__LINE__)[sizeof(BOOST_JOIN(DAHSL_,__LINE__))];
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
dlib/assert.h
View file @
7257589a
...
@@ -95,6 +95,25 @@ namespace dlib
...
@@ -95,6 +95,25 @@ namespace dlib
#define DLIB_IF_ASSERT(exp)
#define DLIB_IF_ASSERT(exp)
#endif
#endif
// ----------------------------------------------------------------------------------------
/*A DLIB_ASSERT_HAS_STANDARD_LAYOUT
This macro is meant to cause a compiler error if a type doesn't have a simple
memory layout (like a C struct). In particular, types with simple layouts are
ones which can be copied via memcpy().
This was called a POD type in C++03 and in C++0x we are looking to check if
it is a "standard layout type". Once we can use C++0x we can change this macro
to something that uses the std::is_standard_layout type_traits class.
See: http://www2.research.att.com/~bs/C++0xFAQ.html#PODs
*/
// Use the fact that in C++03 you can't put non-PODs into a union.
#define DLIB_ASSERT_HAS_STANDARD_LAYOUT(type) \
union BOOST_JOIN(DAHSL_,__LINE__) { type TYPE_NOT_STANDARD_LAYOUT; }; \
typedef char BOOST_JOIN(DAHSL2_,__LINE__)[sizeof(BOOST_JOIN(DAHSL_,__LINE__))];
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
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