mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Merge branch 'master' into exception_fix_new_file
This commit is contained in:
commit
74968d3ef8
@ -32,6 +32,12 @@
|
|||||||
|
|
||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
|
|
||||||
|
#if defined(__cplusplus) && (__cplusplus >= 201703L)
|
||||||
|
#define GSL_NODISCARD [[nodiscard]]
|
||||||
|
#else
|
||||||
|
#define GSL_NODISCARD
|
||||||
|
#endif // defined(__cplusplus) && (__cplusplus >= 201703L)
|
||||||
|
|
||||||
namespace gsl
|
namespace gsl
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -67,13 +73,13 @@ private:
|
|||||||
|
|
||||||
// finally() - convenience function to generate a final_action
|
// finally() - convenience function to generate a final_action
|
||||||
template <class F>
|
template <class F>
|
||||||
final_action<F> finally(const F& f) noexcept
|
GSL_NODISCARD final_action<F> finally(const F& f) noexcept
|
||||||
{
|
{
|
||||||
return final_action<F>(f);
|
return final_action<F>(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class F>
|
template <class F>
|
||||||
final_action<F> finally(F&& f) noexcept
|
GSL_NODISCARD final_action<F> finally(F&& f) noexcept
|
||||||
{
|
{
|
||||||
return final_action<F>(std::forward<F>(f));
|
return final_action<F>(std::forward<F>(f));
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ template <class T>
|
|||||||
class not_null
|
class not_null
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static_assert(std::is_assignable<T&, std::nullptr_t>::value, "T cannot be assigned nullptr.");
|
static_assert(std::is_convertible<decltype(std::declval<T>() != nullptr), bool>::value, "T cannot be compared to nullptr.");
|
||||||
|
|
||||||
template <typename U, typename = std::enable_if_t<std::is_convertible<U, T>::value>>
|
template <typename U, typename = std::enable_if_t<std::is_convertible<U, T>::value>>
|
||||||
constexpr not_null(U&& u) : ptr_(std::forward<U>(u))
|
constexpr not_null(U&& u) : ptr_(std::forward<U>(u))
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
cmake_minimum_required(VERSION 3.0.2)
|
cmake_minimum_required(VERSION 3.0.2)
|
||||||
|
|
||||||
project(GSLTests CXX)
|
project(GSLTests CXX)
|
||||||
|
include(FindPkgConfig)
|
||||||
|
|
||||||
# will make visual studio generated project group files
|
# will make visual studio generated project group files
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
|
pkg_search_module(GTestMain gtest_main)
|
||||||
|
if (NOT GTestMain_FOUND)
|
||||||
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
|
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||||
@ -25,12 +28,14 @@ if(result)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||||
|
set(GTestMain_LIBRARIES gtest_main)
|
||||||
|
|
||||||
add_subdirectory(
|
add_subdirectory(
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||||
EXCLUDE_FROM_ALL
|
EXCLUDE_FROM_ALL
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (MSVC AND (GSL_CXX_STANDARD EQUAL 17))
|
if (MSVC AND (GSL_CXX_STANDARD EQUAL 17))
|
||||||
set(GSL_CPLUSPLUS_OPT -Zc:__cplusplus -permissive-)
|
set(GSL_CPLUSPLUS_OPT -Zc:__cplusplus -permissive-)
|
||||||
@ -149,7 +154,7 @@ function(add_gsl_test name)
|
|||||||
target_link_libraries(${name}
|
target_link_libraries(${name}
|
||||||
GSL
|
GSL
|
||||||
gsl_tests_config
|
gsl_tests_config
|
||||||
gtest_main
|
${GTestMain_LIBRARIES}
|
||||||
)
|
)
|
||||||
add_test(
|
add_test(
|
||||||
${name}
|
${name}
|
||||||
@ -254,7 +259,7 @@ function(add_gsl_test_noexcept name)
|
|||||||
target_link_libraries(${name}
|
target_link_libraries(${name}
|
||||||
GSL
|
GSL
|
||||||
gsl_tests_config_noexcept
|
gsl_tests_config_noexcept
|
||||||
gtest_main
|
${GTestMain_LIBRARIES}
|
||||||
)
|
)
|
||||||
add_test(
|
add_test(
|
||||||
${name}
|
${name}
|
||||||
|
Loading…
Reference in New Issue
Block a user