Skip to content

Commit 3b55b7b

Browse files
committed
Use C++11 language features unconditionally.
Use nullptr, rvalue references, default function template parameters, deleted/defaulted functions, noexcept, final, override and scoped enums. Don't use constexpr yet, as it would raise MSVC requirement.
1 parent fc24312 commit 3b55b7b

24 files changed

+501
-620
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ endif()
7575
add_library(boost_filesystem ${BOOST_FILESYSTEM_SOURCES})
7676
add_library(Boost::filesystem ALIAS boost_filesystem)
7777

78+
target_compile_features(boost_filesystem PUBLIC
79+
cxx_rvalue_references
80+
cxx_strong_enums
81+
cxx_noexcept
82+
cxx_nullptr
83+
cxx_defaulted_functions
84+
cxx_defaulted_move_initializers
85+
cxx_deleted_functions
86+
cxx_default_function_template_args
87+
cxx_final
88+
cxx_override
89+
)
90+
7891
get_target_property(BOOST_FILESYSTEM_TARGET_TYPE boost_filesystem TYPE)
7992
if(BOOST_FILESYSTEM_TARGET_TYPE STREQUAL "SHARED_LIBRARY")
8093
set(CMAKE_REQUIRED_LIBRARIES "-Wl,--no-undefined")

build/Jamfile.v2

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# Boost Filesystem Library Build Jamfile
22

33
# (C) Copyright Beman Dawes 2002-2006
4-
# (C) Copyright Andrey Semashev 2020, 2021
4+
# (C) Copyright Andrey Semashev 2020-2024
55
# Distributed under the Boost Software License, Version 1.0.
66
# See www.boost.org/LICENSE_1_0.txt
77

88
# See library home page at http://www.boost.org/libs/filesystem
99

1010
import project ;
1111
import configure ;
12+
import config : requires ;
1213

1314
lib bcrypt ;
1415
lib advapi32 ;
@@ -122,6 +123,19 @@ rule check-linkflag-no-undefined ( properties * )
122123
return $(result) ;
123124
}
124125

126+
local cxx_requirements = [ requires
127+
cxx11_rvalue_references
128+
cxx11_scoped_enums
129+
cxx11_noexcept
130+
cxx11_nullptr
131+
cxx11_defaulted_functions
132+
cxx11_defaulted_moves
133+
cxx11_deleted_functions
134+
cxx11_function_template_default_args
135+
cxx11_final
136+
cxx11_override
137+
] ;
138+
125139
project boost/filesystem
126140
: requirements
127141
<host-os>hpux,<toolset>gcc:<define>_INCLUDE_STDC__SOURCE_199901
@@ -188,14 +202,17 @@ rule select-platform-specific-sources ( properties * )
188202
}
189203

190204
lib boost_filesystem
191-
: $(SOURCES).cpp
192-
: <define>BOOST_FILESYSTEM_SOURCE
205+
: ## sources ##
206+
$(SOURCES).cpp
207+
: ## requirements ##
208+
<define>BOOST_FILESYSTEM_SOURCE
193209
<conditional>@select-platform-specific-sources
194210
<include>../src
195211
<link>shared:<define>BOOST_FILESYSTEM_DYN_LINK=1
196212
<link>static:<define>BOOST_FILESYSTEM_STATIC_LINK=1
197-
:
198-
:
213+
$(cxx_requirements)
214+
: usage-requirements
215+
$(cxx_requirements)
199216
;
200217

201218
boost-install boost_filesystem ;

include/boost/filesystem/cstdio.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ inline std::FILE* fopen(filesystem::path const& p, const char* mode)
4141
wchar_t buf[128u];
4242
wchar_t* p;
4343

44-
small_array() BOOST_NOEXCEPT : p(buf) {}
45-
~small_array() BOOST_NOEXCEPT
44+
small_array() noexcept : p(buf) {}
45+
~small_array() noexcept
4646
{
4747
if (BOOST_UNLIKELY(p != buf))
4848
std::free(p);
@@ -52,18 +52,18 @@ inline std::FILE* fopen(filesystem::path const& p, const char* mode)
5252
std::size_t wmode_len = std::mbstowcs(wmode.p, mode, sizeof(wmode.buf) / sizeof(wchar_t));
5353
if (BOOST_UNLIKELY(wmode_len >= (sizeof(wmode.buf) / sizeof(wchar_t))))
5454
{
55-
wmode_len = std::mbstowcs(NULL, mode, 0u);
55+
wmode_len = std::mbstowcs(nullptr, mode, 0u);
5656
// Check for size overflow, including (size_t)-1, which indicates mbstowcs error
5757
if (BOOST_UNLIKELY(wmode_len >= (static_cast< std::size_t >(-1) / sizeof(wchar_t))))
58-
return NULL;
58+
return nullptr;
5959

6060
wmode.p = static_cast< wchar_t* >(std::malloc((wmode_len + 1u) * sizeof(wchar_t)));
6161
if (BOOST_UNLIKELY(!wmode.p))
62-
return NULL;
62+
return nullptr;
6363

6464
std::size_t wmode_len2 = std::mbstowcs(wmode.p, mode, wmode_len + 1u);
6565
if (BOOST_UNLIKELY(wmode_len2 > wmode_len))
66-
return NULL;
66+
return nullptr;
6767
}
6868

6969
return ::_wfopen(p.c_str(), wmode.p);

include/boost/filesystem/detail/path_traits.hpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ template< typename, typename, typename > class basic_string;
4949

5050
namespace filesystem {
5151

52-
BOOST_FILESYSTEM_DECL system::error_category const& codecvt_error_category() BOOST_NOEXCEPT;
52+
BOOST_FILESYSTEM_DECL system::error_category const& codecvt_error_category() noexcept;
5353

5454
class directory_entry;
5555

@@ -398,19 +398,19 @@ struct is_native_char_ptr< const path_native_char_type* > :
398398
};
399399

400400

401-
//! Converts character encoding using the supplied codecvt facet. If \a cvt is \c NULL then \c path::codecvt() will be used.
401+
//! Converts character encoding using the supplied codecvt facet. If \a cvt is \c nullptr then \c path::codecvt() will be used.
402402
BOOST_FILESYSTEM_DECL
403-
void convert(const char* from, const char* from_end, std::wstring& to, const codecvt_type* cvt = NULL);
403+
void convert(const char* from, const char* from_end, std::wstring& to, const codecvt_type* cvt = nullptr);
404404

405405
//! \overload convert
406406
BOOST_FILESYSTEM_DECL
407-
void convert(const wchar_t* from, const wchar_t* from_end, std::string& to, const codecvt_type* cvt = NULL);
407+
void convert(const wchar_t* from, const wchar_t* from_end, std::string& to, const codecvt_type* cvt = nullptr);
408408

409409

410410
// Source dispatch -----------------------------------------------------------------//
411411

412412
template< typename Source, typename Callback >
413-
typename Callback::result_type dispatch(Source const& source, Callback cb, const codecvt_type* cvt = NULL);
413+
typename Callback::result_type dispatch(Source const& source, Callback cb, const codecvt_type* cvt = nullptr);
414414

415415
template< typename Callback >
416416
BOOST_FORCEINLINE typename Callback::result_type dispatch(const char* source, Callback cb, const codecvt_type* cvt, ntcts_type_tag)
@@ -442,7 +442,7 @@ BOOST_FORCEINLINE typename Callback::result_type dispatch(Source const& source,
442442
template< typename Callback >
443443
BOOST_FORCEINLINE typename Callback::result_type dispatch(std::vector< char > const& source, Callback cb, const codecvt_type* cvt, range_type_tag)
444444
{
445-
const char* data = NULL, *data_end = NULL;
445+
const char* data = nullptr, *data_end = nullptr;
446446
if (!source.empty())
447447
{
448448
data = &source[0];
@@ -454,7 +454,7 @@ BOOST_FORCEINLINE typename Callback::result_type dispatch(std::vector< char > co
454454
template< typename Callback >
455455
BOOST_FORCEINLINE typename Callback::result_type dispatch(std::vector< wchar_t > const& source, Callback cb, const codecvt_type* cvt, range_type_tag)
456456
{
457-
const wchar_t* data = NULL, *data_end = NULL;
457+
const wchar_t* data = nullptr, *data_end = nullptr;
458458
if (!source.empty())
459459
{
460460
data = &source[0];
@@ -496,9 +496,7 @@ yes_type check_convertible(std::wstring_view const&);
496496
#endif
497497
yes_type check_convertible(boost::basic_string_view< char, std::char_traits< char > > const&);
498498
yes_type check_convertible(boost::basic_string_view< wchar_t, std::char_traits< wchar_t > > const&);
499-
#if !defined(BOOST_NO_CXX11_NULLPTR)
500499
no_type check_convertible(std::nullptr_t);
501-
#endif
502500
no_type check_convertible(...);
503501

504502
} // namespace is_convertible_to_path_source_impl
@@ -525,9 +523,7 @@ namespace is_convertible_to_std_string_view_impl {
525523

526524
yes_type check_convertible(std::string_view const&);
527525
yes_type check_convertible(std::wstring_view const&);
528-
#if !defined(BOOST_NO_CXX11_NULLPTR)
529526
no_type check_convertible(std::nullptr_t);
530-
#endif
531527
no_type check_convertible(...);
532528

533529
} // namespace is_convertible_to_std_string_view_impl
@@ -551,9 +547,7 @@ yes_type check_convertible(boost::container::basic_string< char, std::char_trait
551547
yes_type check_convertible(boost::container::basic_string< wchar_t, std::char_traits< wchar_t >, void > const&);
552548
yes_type check_convertible(boost::basic_string_view< char, std::char_traits< char > > const&);
553549
yes_type check_convertible(boost::basic_string_view< wchar_t, std::char_traits< wchar_t > > const&);
554-
#if !defined(BOOST_NO_CXX11_NULLPTR)
555550
no_type check_convertible(std::nullptr_t);
556-
#endif
557551
no_type check_convertible(...);
558552

559553
} // namespace is_convertible_to_path_source_non_std_string_view_impl
@@ -683,7 +677,7 @@ BOOST_FORCEINLINE typename Callback::result_type dispatch_convertible_impl(std::
683677
#endif // !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
684678

685679
template< typename Source, typename Callback >
686-
BOOST_FORCEINLINE typename Callback::result_type dispatch_convertible(Source const& source, Callback cb, const codecvt_type* cvt = NULL)
680+
BOOST_FORCEINLINE typename Callback::result_type dispatch_convertible(Source const& source, Callback cb, const codecvt_type* cvt = nullptr)
687681
{
688682
typedef typename boost::remove_cv< Source >::type source_t;
689683
return path_traits::dispatch_convertible_impl< source_t >(source, cb, cvt);
@@ -709,7 +703,7 @@ template< typename Source, typename Callback >
709703
BOOST_FORCEINLINE typename boost::disable_if_c<
710704
is_convertible_to_std_string_view< typename boost::remove_cv< Source >::type >::value,
711705
typename Callback::result_type
712-
>::type dispatch_convertible(Source const& source, Callback cb, const codecvt_type* cvt = NULL)
706+
>::type dispatch_convertible(Source const& source, Callback cb, const codecvt_type* cvt = nullptr)
713707
{
714708
typedef typename boost::remove_cv< Source >::type source_t;
715709
return path_traits::dispatch_convertible_impl< source_t >(source, cb, cvt);
@@ -719,7 +713,7 @@ template< typename Source, typename Callback >
719713
BOOST_FORCEINLINE typename boost::enable_if_c<
720714
is_convertible_to_std_string_view< typename boost::remove_cv< Source >::type >::value,
721715
typename Callback::result_type
722-
>::type dispatch_convertible(Source const& source, Callback cb, const codecvt_type* cvt = NULL)
716+
>::type dispatch_convertible(Source const& source, Callback cb, const codecvt_type* cvt = nullptr)
723717
{
724718
typedef typename boost::remove_cv< Source >::type source_t;
725719
return path_traits::dispatch_convertible_sv_impl< source_t >(source, cb, cvt);

0 commit comments

Comments
 (0)