Prohibit default construction of function_output_iterator on function pointers.

Default-constructed function_output_iterator with function pointers is unusable
and previously would have contained an uninitialized function pointer.
Disable the default constructor using SFINAE to prevent misuse.

Also reformat code.
This commit is contained in:
Andrey Semashev
2025-02-07 01:17:55 +03:00
parent fd1445140f
commit a91fc06bb4
3 changed files with 64 additions and 42 deletions
+1
View File
@@ -58,6 +58,7 @@ test-suite iterator
[ run function_input_iterator_test.cpp ]
[ run function_output_iterator_test.cpp ]
[ compile-fail function_output_iterator_cf.cpp ]
[ compile-fail function_output_iterator_def_ctor_cf.cpp ]
[ run generator_iterator_test.cpp ]
@@ -0,0 +1,14 @@
// Copyright 2025 (c) Andrey Semashev
// Distributed under the Boost Software License Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/iterator/function_output_iterator.hpp>
int main()
{
boost::iterators::function_output_iterator< void (*)(int) > it;
(void)it;
return 0;
}