#193 Dropped support for boot::shared_ptr<>, enabled C++11 support in CMake
This commit is contained in:
parent
ed825ba255
commit
8564b2f8b0
@ -12,7 +12,7 @@
|
||||
# http://www.cmake.org
|
||||
#
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6 FATAL_ERROR)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.1 FATAL_ERROR)
|
||||
|
||||
INCLUDE(cmake/Utils.cmake)
|
||||
|
||||
@ -68,6 +68,11 @@ SET(VMIME_API_VERSION ${VMIME_API_VERSION_CURRENT}.${VMIME_API_VERSION_REVISION}
|
||||
# Set base name
|
||||
SET(VMIME_LIBRARY_NAME vmime)
|
||||
|
||||
# Enable C++11
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
SET(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# Source files
|
||||
FILE(
|
||||
GLOB_RECURSE
|
||||
@ -795,89 +800,6 @@ ELSE()
|
||||
ENDIF()
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Language features
|
||||
|
||||
# C++11
|
||||
INCLUDE(cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake)
|
||||
|
||||
# Smart pointers
|
||||
#
|
||||
# If a C++11-compliant compiler is available and supports std::shared_ptr<>,
|
||||
# use the standard implementation. Else, use boost::shared_ptr<>.
|
||||
# In any case, let the user override the choice with VMIME_SHARED_PTR_USE_CXX
|
||||
# and VMIME_SHARED_PTR_USE_BOOST variables.
|
||||
|
||||
CHECK_CXX_SOURCE_COMPILES(
|
||||
"
|
||||
#include <memory>
|
||||
struct A { int foo; };
|
||||
int main() {
|
||||
std::shared_ptr <A> a = std::make_shared <A>();
|
||||
return 0;
|
||||
}
|
||||
"
|
||||
VMIME_HAS_CXX11_SHARED_PTR
|
||||
)
|
||||
|
||||
IF(NOT VMIME_SHARED_PTR_USE_CXX AND NOT VMIME_SHARED_PTR_USE_BOOST)
|
||||
IF(CXX11_COMPILER_FLAGS AND VMIME_HAS_CXX11_SHARED_PTR)
|
||||
# If std::shared_ptr<> is available, use it by default
|
||||
SET(VMIME_SHARED_PTR_USE_CXX_DEFAULT ON)
|
||||
SET(VMIME_SHARED_PTR_USE_BOOST_DEFAULT OFF)
|
||||
ELSE()
|
||||
# Else, set default to boost::shared_ptr<>
|
||||
SET(VMIME_SHARED_PTR_USE_CXX_DEFAULT OFF)
|
||||
SET(VMIME_SHARED_PTR_USE_BOOST_DEFAULT ON)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
OPTION(
|
||||
VMIME_SHARED_PTR_USE_CXX
|
||||
"Use standard std::shared_ptr<> (requires a C++11 compiler)"
|
||||
${VMIME_SHARED_PTR_USE_CXX_DEFAULT}
|
||||
)
|
||||
|
||||
OPTION(
|
||||
VMIME_SHARED_PTR_USE_BOOST
|
||||
"Use boost::shared_ptr<> (requires Boost)"
|
||||
${VMIME_SHARED_PTR_USE_BOOST_DEFAULT}
|
||||
)
|
||||
|
||||
IF(VMIME_SHARED_PTR_USE_CXX AND VMIME_SHARED_PTR_USE_BOOST)
|
||||
MESSAGE(FATAL_ERROR "Options VMIME_SHARED_PTR_USE_CXX and VMIME_SHARED_PTR_USE_BOOST are mutually exclusive (select one or the other, but not both!)")
|
||||
ENDIF()
|
||||
|
||||
IF(VMIME_SHARED_PTR_USE_CXX)
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")
|
||||
|
||||
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "Checking support for shared_ptr<>: built-in (C++11)")
|
||||
|
||||
ELSEIF(VMIME_SHARED_PTR_USE_BOOST)
|
||||
|
||||
# Depends on Boost library if C++11 is not supported
|
||||
FIND_PACKAGE(Boost)
|
||||
|
||||
IF(Boost_FOUND)
|
||||
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Boost library is required for shared_ptr<>, unless you compile using C++11")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "Checking support for shared_ptr<>: boost library")
|
||||
|
||||
ELSE()
|
||||
|
||||
MESSAGE(FATAL_ERROR "No implementation for shared_ptr<> was selected/found")
|
||||
|
||||
ENDIF()
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Platform
|
||||
|
||||
|
1
cmake/cmake-cxx11/.gitignore
vendored
1
cmake/cmake-cxx11/.gitignore
vendored
@ -1 +0,0 @@
|
||||
build
|
@ -1,7 +0,0 @@
|
||||
These things need to be changed when this module is merged into CMake:
|
||||
|
||||
-change include(CheckCXXCompilerFlag) in CheckCXX11Features.cmake to
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXCompilerFlag.cmake)
|
||||
-remove the setting of CMAKE_MODULE_PATH from the testcase CMakeLists.txt
|
||||
-change all tabs to spaces in the cpp files
|
||||
|
@ -1,142 +0,0 @@
|
||||
# - Check which parts of the C++11 standard the compiler supports
|
||||
#
|
||||
# When found it will set the following variables
|
||||
#
|
||||
# CXX11_COMPILER_FLAGS - the compiler flags needed to get C++11 features
|
||||
#
|
||||
# HAS_CXX11_AUTO - auto keyword
|
||||
# HAS_CXX11_AUTO_RET_TYPE - function declaration with deduced return types
|
||||
# HAS_CXX11_CLASS_OVERRIDE - override and final keywords for classes and methods
|
||||
# HAS_CXX11_CONSTEXPR - constexpr keyword
|
||||
# HAS_CXX11_CSTDINT_H - cstdint header
|
||||
# HAS_CXX11_DECLTYPE - decltype keyword
|
||||
# HAS_CXX11_FUNC - __func__ preprocessor constant
|
||||
# HAS_CXX11_INITIALIZER_LIST - initializer list
|
||||
# HAS_CXX11_LAMBDA - lambdas
|
||||
# HAS_CXX11_LIB_REGEX - regex library
|
||||
# HAS_CXX11_LONG_LONG - long long signed & unsigned types
|
||||
# HAS_CXX11_NULLPTR - nullptr
|
||||
# HAS_CXX11_RVALUE_REFERENCES - rvalue references
|
||||
# HAS_CXX11_SIZEOF_MEMBER - sizeof() non-static members
|
||||
# HAS_CXX11_STATIC_ASSERT - static_assert()
|
||||
# HAS_CXX11_VARIADIC_TEMPLATES - variadic templates
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2011,2012 Rolf Eike Beer <eike@sf-mail.de>
|
||||
# Copyright 2012 Andreas Weis
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
#
|
||||
# Each feature may have up to 3 checks, every one of them in it's own file
|
||||
# FEATURE.cpp - example that must build and return 0 when run
|
||||
# FEATURE_fail.cpp - example that must build, but may not return 0 when run
|
||||
# FEATURE_fail_compile.cpp - example that must fail compilation
|
||||
#
|
||||
# The first one is mandatory, the latter 2 are optional and do not depend on
|
||||
# each other (i.e. only one may be present).
|
||||
#
|
||||
|
||||
if (NOT CMAKE_CXX_COMPILER_LOADED)
|
||||
message(FATAL_ERROR "CheckCXX11Features modules only works if language CXX is enabled")
|
||||
endif ()
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
|
||||
#
|
||||
### Check for needed compiler flags
|
||||
#
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag("-std=c++11" _HAS_CXX11_FLAG)
|
||||
if (NOT _HAS_CXX11_FLAG)
|
||||
check_cxx_compiler_flag("-std=c++0x" _HAS_CXX0X_FLAG)
|
||||
endif ()
|
||||
|
||||
if (_HAS_CXX11_FLAG)
|
||||
set(CXX11_COMPILER_FLAGS "-std=c++11")
|
||||
elseif (_HAS_CXX0X_FLAG)
|
||||
set(CXX11_COMPILER_FLAGS "-std=c++0x")
|
||||
endif ()
|
||||
|
||||
function(cxx11_check_feature FEATURE_NAME RESULT_VAR)
|
||||
if (NOT DEFINED ${RESULT_VAR})
|
||||
set(_bindir "${CMAKE_CURRENT_BINARY_DIR}/cxx11_${FEATURE_NAME}")
|
||||
|
||||
set(_SRCFILE_BASE ${CMAKE_CURRENT_LIST_DIR}/CheckCXX11Features/cxx11-test-${FEATURE_NAME})
|
||||
set(_LOG_NAME "\"${FEATURE_NAME}\"")
|
||||
message(STATUS "Checking C++11 support for ${_LOG_NAME}")
|
||||
|
||||
set(_SRCFILE "${_SRCFILE_BASE}.cpp")
|
||||
set(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp")
|
||||
set(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp")
|
||||
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}"
|
||||
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
|
||||
if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
|
||||
try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}"
|
||||
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
|
||||
endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
|
||||
else (CMAKE_CROSSCOMPILING)
|
||||
try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
|
||||
"${_bindir}" "${_SRCFILE}"
|
||||
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
|
||||
if (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
|
||||
set(${RESULT_VAR} TRUE)
|
||||
else (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
|
||||
set(${RESULT_VAR} FALSE)
|
||||
endif (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
|
||||
if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
|
||||
try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
|
||||
"${_bindir}_fail" "${_SRCFILE_FAIL}"
|
||||
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
|
||||
if (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
|
||||
set(${RESULT_VAR} TRUE)
|
||||
else (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
|
||||
set(${RESULT_VAR} FALSE)
|
||||
endif (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
|
||||
endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
|
||||
endif (CMAKE_CROSSCOMPILING)
|
||||
if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
|
||||
try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}"
|
||||
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
|
||||
if (_TMP_RESULT)
|
||||
set(${RESULT_VAR} FALSE)
|
||||
else (_TMP_RESULT)
|
||||
set(${RESULT_VAR} TRUE)
|
||||
endif (_TMP_RESULT)
|
||||
endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
|
||||
|
||||
if (${RESULT_VAR})
|
||||
message(STATUS "Checking C++11 support for ${_LOG_NAME}: works")
|
||||
else (${RESULT_VAR})
|
||||
message(STATUS "Checking C++11 support for ${_LOG_NAME}: not supported")
|
||||
endif (${RESULT_VAR})
|
||||
set(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}")
|
||||
endif (NOT DEFINED ${RESULT_VAR})
|
||||
endfunction(cxx11_check_feature)
|
||||
|
||||
cxx11_check_feature("__func__" HAS_CXX11_FUNC)
|
||||
cxx11_check_feature("auto" HAS_CXX11_AUTO)
|
||||
cxx11_check_feature("auto_ret_type" HAS_CXX11_AUTO_RET_TYPE)
|
||||
cxx11_check_feature("class_override_final" HAS_CXX11_CLASS_OVERRIDE)
|
||||
cxx11_check_feature("constexpr" HAS_CXX11_CONSTEXPR)
|
||||
cxx11_check_feature("cstdint" HAS_CXX11_CSTDINT_H)
|
||||
cxx11_check_feature("decltype" HAS_CXX11_DECLTYPE)
|
||||
cxx11_check_feature("initializer_list" HAS_CXX11_INITIALIZER_LIST)
|
||||
cxx11_check_feature("lambda" HAS_CXX11_LAMBDA)
|
||||
cxx11_check_feature("long_long" HAS_CXX11_LONG_LONG)
|
||||
cxx11_check_feature("nullptr" HAS_CXX11_NULLPTR)
|
||||
cxx11_check_feature("regex" HAS_CXX11_LIB_REGEX)
|
||||
cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES)
|
||||
cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER)
|
||||
cxx11_check_feature("static_assert" HAS_CXX11_STATIC_ASSERT)
|
||||
cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES)
|
@ -1,8 +0,0 @@
|
||||
int main(void)
|
||||
{
|
||||
if (!__func__)
|
||||
return 1;
|
||||
if (!(*__func__))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
auto i = 5;
|
||||
auto f = 3.14159f;
|
||||
auto d = 3.14159;
|
||||
bool ret = (
|
||||
(sizeof(f) < sizeof(d)) &&
|
||||
(sizeof(i) == sizeof(int))
|
||||
);
|
||||
return ret ? 0 : 1;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
int main(void)
|
||||
{
|
||||
// must fail because there is no initializer
|
||||
auto i;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
auto foo(int i) -> int {
|
||||
return i - 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
return foo(1);
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
class base {
|
||||
public:
|
||||
virtual int foo(int a)
|
||||
{ return 4 + a; }
|
||||
int bar(int a) final
|
||||
{ return a - 2; }
|
||||
};
|
||||
|
||||
class sub final : public base {
|
||||
public:
|
||||
virtual int foo(int a) override
|
||||
{ return 8 + 2 * a; };
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
base b;
|
||||
sub s;
|
||||
|
||||
return (b.foo(2) * 2 == s.foo(2)) ? 0 : 1;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
class base {
|
||||
public:
|
||||
virtual int foo(int a)
|
||||
{ return 4 + a; }
|
||||
virtual int bar(int a) final
|
||||
{ return a - 2; }
|
||||
};
|
||||
|
||||
class sub final : public base {
|
||||
public:
|
||||
virtual int foo(int a) override
|
||||
{ return 8 + 2 * a; };
|
||||
virtual int bar(int a)
|
||||
{ return a; }
|
||||
};
|
||||
|
||||
class impossible : public sub { };
|
||||
|
||||
int main(void)
|
||||
{
|
||||
base b;
|
||||
sub s;
|
||||
|
||||
return 1;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
constexpr int square(int x)
|
||||
{
|
||||
return x*x;
|
||||
}
|
||||
|
||||
constexpr int the_answer()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int test_arr[square(3)];
|
||||
bool ret = (
|
||||
(square(the_answer()) == 1764) &&
|
||||
(sizeof(test_arr)/sizeof(test_arr[0]) == 9)
|
||||
);
|
||||
return ret ? 0 : 1;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
#include <cstdint>
|
||||
|
||||
int main()
|
||||
{
|
||||
bool test =
|
||||
(sizeof(int8_t) == 1) &&
|
||||
(sizeof(int16_t) == 2) &&
|
||||
(sizeof(int32_t) == 4) &&
|
||||
(sizeof(int64_t) == 8);
|
||||
return test ? 0 : 1;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
bool check_size(int i)
|
||||
{
|
||||
return sizeof(int) == sizeof(decltype(i));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
bool ret = check_size(42);
|
||||
return ret ? 0 : 1;
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
#include <vector>
|
||||
|
||||
class seq {
|
||||
public:
|
||||
seq(std::initializer_list<int> list);
|
||||
|
||||
int length() const;
|
||||
private:
|
||||
std::vector<int> m_v;
|
||||
};
|
||||
|
||||
seq::seq(std::initializer_list<int> list)
|
||||
: m_v(list)
|
||||
{
|
||||
}
|
||||
|
||||
int seq::length() const
|
||||
{
|
||||
return m_v.size();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
seq a = {18, 20, 2, 0, 4, 7};
|
||||
|
||||
return (a.length() == 6) ? 0 : 1;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
int main()
|
||||
{
|
||||
int ret = 0;
|
||||
return ([&ret]() -> int { return ret; })();
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
int main(void)
|
||||
{
|
||||
long long l;
|
||||
unsigned long long ul;
|
||||
|
||||
return ((sizeof(l) >= 8) && (sizeof(ul) >= 8)) ? 0 : 1;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
int main(void)
|
||||
{
|
||||
void *v = nullptr;
|
||||
|
||||
return v ? 1 : 0;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
int main(void)
|
||||
{
|
||||
int i = nullptr;
|
||||
|
||||
return 1;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
#include <algorithm>
|
||||
#include <regex>
|
||||
|
||||
int parse_line(std::string const& line)
|
||||
{
|
||||
std::string tmp;
|
||||
if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+//(-)?(\\d)+(\\s)+"))) {
|
||||
tmp = std::regex_replace(line, std::regex("(-)?(\\d)+//(-)?(\\d)+"), std::string("V"));
|
||||
} else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
|
||||
tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
|
||||
} else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
|
||||
tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
|
||||
} else {
|
||||
tmp = std::regex_replace(line, std::regex("(-)?(\\d)+"), std::string("V"));
|
||||
}
|
||||
return static_cast<int>(std::count(tmp.begin(), tmp.end(), 'V'));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
bool test = (parse_line("f 7/7/7 -3/3/-3 2/-2/2") == 3) &&
|
||||
(parse_line("f 7//7 3//-3 -2//2") == 3) &&
|
||||
(parse_line("f 7/7 3/-3 -2/2") == 3) &&
|
||||
(parse_line("f 7 3 -2") == 3);
|
||||
return test ? 0 : 1;
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
#include <cassert>
|
||||
|
||||
class rvmove {
|
||||
public:
|
||||
void *ptr;
|
||||
char *array;
|
||||
|
||||
rvmove()
|
||||
: ptr(0),
|
||||
array(new char[10])
|
||||
{
|
||||
ptr = this;
|
||||
}
|
||||
|
||||
rvmove(rvmove &&other)
|
||||
: ptr(other.ptr),
|
||||
array(other.array)
|
||||
{
|
||||
other.array = 0;
|
||||
other.ptr = 0;
|
||||
}
|
||||
|
||||
~rvmove()
|
||||
{
|
||||
assert(((ptr != 0) && (array != 0)) || ((ptr == 0) && (array == 0)));
|
||||
delete[] array;
|
||||
}
|
||||
|
||||
rvmove &operator=(rvmove &&other)
|
||||
{
|
||||
delete[] array;
|
||||
ptr = other.ptr;
|
||||
array = other.array;
|
||||
other.array = 0;
|
||||
other.ptr = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
static rvmove create()
|
||||
{
|
||||
return rvmove();
|
||||
}
|
||||
private:
|
||||
rvmove(const rvmove &);
|
||||
rvmove &operator=(const rvmove &);
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
rvmove mine;
|
||||
if (mine.ptr != &mine)
|
||||
return 1;
|
||||
mine = rvmove::create();
|
||||
if (mine.ptr == &mine)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
struct foo {
|
||||
char bar;
|
||||
int baz;
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
bool ret = (
|
||||
(sizeof(foo::bar) == 1) &&
|
||||
(sizeof(foo::baz) >= sizeof(foo::bar)) &&
|
||||
(sizeof(foo) >= sizeof(foo::bar) + sizeof(foo::baz))
|
||||
);
|
||||
return ret ? 0 : 1;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
struct foo {
|
||||
int baz;
|
||||
double bar;
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return (sizeof(foo::bar) == 4) ? 0 : 1;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
int main(void)
|
||||
{
|
||||
static_assert(0 < 1, "your ordering of integers is screwed");
|
||||
return 0;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
int main(void)
|
||||
{
|
||||
static_assert(1 < 0, "your ordering of integers is screwed");
|
||||
return 0;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
int Accumulate()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename T, typename... Ts>
|
||||
int Accumulate(T v, Ts... vs)
|
||||
{
|
||||
return v + Accumulate(vs...);
|
||||
}
|
||||
|
||||
template<int... Is>
|
||||
int CountElements()
|
||||
{
|
||||
return sizeof...(Is);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int acc = Accumulate(1, 2, 3, 4, -5);
|
||||
int count = CountElements<1,2,3,4,5>();
|
||||
return ((acc == 5) && (count == 5)) ? 0 : 1;
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR)
|
||||
project(Cxx11Features CXX)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules")
|
||||
|
||||
include(CheckCXX11Features)
|
||||
|
||||
foreach (flag IN ITEMS
|
||||
HAS_CXX11_AUTO
|
||||
HAS_CXX11_AUTO_RET_TYPE
|
||||
HAS_CXX11_CLASS_OVERRIDE
|
||||
HAS_CXX11_CONSTEXPR
|
||||
HAS_CXX11_CSTDINT_H
|
||||
HAS_CXX11_DECLTYPE
|
||||
HAS_CXX11_FUNC
|
||||
HAS_CXX11_INITIALIZER_LIST
|
||||
HAS_CXX11_LAMBDA
|
||||
HAS_CXX11_LIB_REGEX
|
||||
HAS_CXX11_LONG_LONG
|
||||
HAS_CXX11_NULLPTR
|
||||
HAS_CXX11_RVALUE_REFERENCES
|
||||
HAS_CXX11_SIZEOF_MEMBER
|
||||
HAS_CXX11_STATIC_ASSERT
|
||||
HAS_CXX11_VARIADIC_TEMPLATES
|
||||
)
|
||||
if (${flag})
|
||||
add_definitions("-D${flag}")
|
||||
message(STATUS "Compiler C++11 support flag ${flag} set")
|
||||
endif ()
|
||||
endforeach (flag)
|
||||
|
||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS})
|
||||
add_executable(CXX11Features cxx11features.cxx)
|
@ -1,57 +0,0 @@
|
||||
#if defined(HAS_CXX0X_CSTDINT_H)
|
||||
#include <cstdint>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
struct thing {
|
||||
unsigned char one;
|
||||
#if defined(HAS_CXX0X_CSTDINT_H)
|
||||
uint32_t four;
|
||||
#endif
|
||||
#if defined(HAS_CXX0X_LONG_LONG)
|
||||
long long eight;
|
||||
#endif
|
||||
};
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if defined (HAS_CXX0X_NULLPTR)
|
||||
void *nix = nullptr;
|
||||
#else /* HAS_CXX0X_NULLPTR */
|
||||
void *nix = 0;
|
||||
#endif /* HAS_CXX0X_NULLPTR */
|
||||
|
||||
#if defined(HAS_CXX0X_STATIC_ASSERT)
|
||||
static_assert(1 < 42, "Your C++ compiler is b0rked");
|
||||
#endif /* HAS_CXX0X_STATIC_ASSERT */
|
||||
|
||||
#if defined(HAS_CXX0X_FUNC)
|
||||
const char *funcname = __func__;
|
||||
printf("the name of main() function is: %s\n", funcname);
|
||||
#endif /* HAS_CXX0X_FUNC */
|
||||
|
||||
#if defined(HAS_CXX0X_SIZEOF_MEMBER)
|
||||
size_t onesize = sizeof(thing::one);
|
||||
#if defined(HAS_CXX0X_STATIC_ASSERT)
|
||||
static_assert(sizeof(thing::one) == 1, "Your char is not one byte long");
|
||||
#endif /* HAS_CXX0X_STATIC_ASSERT */
|
||||
|
||||
#if defined(HAS_CXX0X_CSTDINT_H)
|
||||
size_t foursize = sizeof(thing::four);
|
||||
#if defined(HAS_CXX0X_STATIC_ASSERT)
|
||||
static_assert(sizeof(thing::four) == 4, "Your uint32_t is not 32 bit long");
|
||||
#endif /* HAS_CXX0X_STATIC_ASSERT */
|
||||
#endif /* HAS_CXX0X_CSTDINT_H */
|
||||
#if defined(HAS_CXX0X_LONG_LONG)
|
||||
size_t eightsize = sizeof(thing::eight);
|
||||
#if defined(HAS_CXX0X_STATIC_ASSERT)
|
||||
static_assert(sizeof(thing::eight) == 8, "Your long long is not 64 bit long");
|
||||
#endif /* HAS_CXX0X_STATIC_ASSERT */
|
||||
#endif /* HAS_CXX0X_LONG_LONG */
|
||||
#endif /* HAS_CXX0X_SIZEOF_MEMBER */
|
||||
|
||||
return 0;
|
||||
}
|
@ -25,8 +25,6 @@ want SASL\footnote{Simple Authentication and Security Layer} support ;
|
||||
\item either the \href{http://www.openssl.org}{OpenSSL library} or the
|
||||
\href{http://www.gnu.org/software/gnutls/}{GNU TLS Library} if you
|
||||
want SSL and TLS\footnote{Transport Layer Security} support ;
|
||||
\item the \href{http://www.boost.org}{Boost C++ library} if you are not using
|
||||
C++11 (or your compiler does not support it), for {\vcode shared\_ptr<>}.
|
||||
\end{itemize}
|
||||
|
||||
% ============================================================================
|
||||
|
@ -31,42 +31,24 @@
|
||||
#include <stdexcept>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
|
||||
#include "vmime/config.hpp"
|
||||
|
||||
|
||||
#ifndef VMIME_BUILDING_DOC
|
||||
|
||||
#if VMIME_SHARED_PTR_USE_CXX
|
||||
// If we are compiling with C++11, use shared_ptr<> from the standard lib
|
||||
#include <memory>
|
||||
|
||||
#define VMIME_SHARED_PTR_NAMESPACE std
|
||||
#elif VMIME_SHARED_PTR_USE_BOOST
|
||||
// Else, use boost's shared_ptr<>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#define VMIME_SHARED_PTR_NAMESPACE boost
|
||||
#else
|
||||
#error Either VMIME_SHAREDPTR_USE_CXX or VMIME_SHAREDPTR_USE_BOOST must be set to ON
|
||||
#endif
|
||||
|
||||
namespace vmime
|
||||
{
|
||||
using VMIME_SHARED_PTR_NAMESPACE::shared_ptr;
|
||||
using VMIME_SHARED_PTR_NAMESPACE::weak_ptr;
|
||||
using VMIME_SHARED_PTR_NAMESPACE::make_shared;
|
||||
using VMIME_SHARED_PTR_NAMESPACE::enable_shared_from_this;
|
||||
using VMIME_SHARED_PTR_NAMESPACE::dynamic_pointer_cast;
|
||||
using VMIME_SHARED_PTR_NAMESPACE::const_pointer_cast;
|
||||
using std::shared_ptr;
|
||||
using std::weak_ptr;
|
||||
using std::make_shared;
|
||||
using std::enable_shared_from_this;
|
||||
using std::dynamic_pointer_cast;
|
||||
using std::const_pointer_cast;
|
||||
|
||||
/** Custom deleter to be used with shared_ptr.
|
||||
* This is does not actually delete the pointer, and is used
|
||||
* This does not actually delete the pointer, and is used
|
||||
* only for the singleton classes allocated on the stack.
|
||||
*/
|
||||
template <typename T>
|
||||
@ -75,15 +57,9 @@ namespace vmime
|
||||
void operator()(T*) const {}
|
||||
};
|
||||
|
||||
#if VMIME_SHARED_PTR_USE_CXX
|
||||
template <typename T> using scoped_ptr = std::unique_ptr <T>;
|
||||
#else
|
||||
using VMIME_SHARED_PTR_NAMESPACE::scoped_ptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef VMIME_SHARED_PTR_NAMESPACE
|
||||
|
||||
#endif // VMIME_BUILDING_DOC
|
||||
|
||||
|
||||
@ -103,16 +79,6 @@ namespace vmime
|
||||
// For compatibility with versions <= 0.7.1 (deprecated)
|
||||
namespace net { }
|
||||
namespace messaging = net;
|
||||
|
||||
// For (minimal) compatibility with legacy smart pointers (<= 0.9.1)
|
||||
// Your compiler must have support for C++11
|
||||
#if VMIME_COMPAT_LEGACY_SMART_POINTERS
|
||||
template <typename T> using ref = shared_ptr <T>;
|
||||
class creator {}; // unused
|
||||
template <typename T, typename... Args>
|
||||
inline shared_ptr <T> create(Args&&... args) { return make_shared <T>(args...); }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user