2
0
mirror of https://github.com/boostorg/scope.git synced 2026-01-19 04:42:10 +00:00
Files
scope/test/compile_fail/scope_exit_cond_def_cted_fptr.cpp
Andrey Semashev 80d26d6909 Prevent default-construction of function pointers.
Default- and value-constructed pointers to functions are not callable,
and therefore are not accepted as default-constructible condition
function objects and deleters.

Closes https://github.com/Lastique/scope/issues/14.
2023-12-17 19:16:08 +03:00

26 lines
622 B
C++

/*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* https://www.boost.org/LICENSE_1_0.txt)
*
* Copyright (c) 2023 Andrey Semashev
*/
/*!
* \file scope_exit_cond_def_cted_fptr.cpp
* \author Andrey Semashev
*
* \brief This file tests that \c scope_exit with a function pointer
* condition function object cannot be default-constructed.
*/
#include <boost/scope/scope_exit.hpp>
#include "function_types.hpp"
int main()
{
int n = 0;
boost::scope::scope_exit< normal_func, bool (*)() > guard{ normal_func(n) };
return 0;
}