mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-10 05:10:05 +00:00
Use explicitly deleted functions to make types non-copyable
This commit is contained in:
parent
f77350f8fa
commit
2eef573656
@ -117,6 +117,17 @@ endif ()
|
|||||||
# add_definitions(-DFMT_USE_NOEXCEPT=1)
|
# add_definitions(-DFMT_USE_NOEXCEPT=1)
|
||||||
#endif ()
|
#endif ()
|
||||||
|
|
||||||
|
#check_cxx_source_compiles("
|
||||||
|
# struct C{
|
||||||
|
# C()=delete;
|
||||||
|
# C(const C&)=delete;
|
||||||
|
# C& operator=(const C&)=delete;
|
||||||
|
# };
|
||||||
|
# int main(){}" FMT_DELETED_FUNCTIONS)
|
||||||
|
#if (FMT_DELETED_FUNCTIONS)
|
||||||
|
# add_definitions(-DFMT_USE_DELETED_FUNCTIONS=1)
|
||||||
|
#endif ()
|
||||||
|
|
||||||
# GTest doesn't detect <tuple> with clang.
|
# GTest doesn't detect <tuple> with clang.
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
target_compile_definitions(gmock PUBLIC GTEST_USE_OWN_TR1_TUPLE=1)
|
target_compile_definitions(gmock PUBLIC GTEST_USE_OWN_TR1_TUPLE=1)
|
||||||
|
13
format.h
13
format.h
@ -121,9 +121,16 @@
|
|||||||
|
|
||||||
// A macro to disallow the copy constructor and operator= functions
|
// A macro to disallow the copy constructor and operator= functions
|
||||||
// This should be used in the private: declarations for a class
|
// This should be used in the private: declarations for a class
|
||||||
#define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
#if FMT_USE_DELETED_FUNCTIONS || FMT_HAS_FEATURE(cxx_deleted_functions) || \
|
||||||
TypeName(const TypeName&); \
|
(FMT_GCC_VERSION >= 404 && __cplusplus >= 201103L) || _MSC_VER >= 1800
|
||||||
void operator=(const TypeName&)
|
# define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||||
|
TypeName(const TypeName&) = delete; \
|
||||||
|
TypeName& operator=(const TypeName&) = delete
|
||||||
|
#else
|
||||||
|
# define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||||
|
TypeName(const TypeName&); \
|
||||||
|
TypeName& operator=(const TypeName&)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace fmt {
|
namespace fmt {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user