TLA Line data Source code
1 : //
2 : // Copyright (c) 2025 Alan de Freitas (alandefreitas@gmail.com)
3 : //
4 : // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 : //
7 : // Official repository: https://github.com/boostorg/url
8 : //
9 :
10 : #ifndef BOOST_URL_DETAIL_MEMCPY_HPP
11 : #define BOOST_URL_DETAIL_MEMCPY_HPP
12 :
13 : #include <boost/url/detail/config.hpp>
14 : #include <cstddef>
15 : #include <cstring>
16 :
17 : namespace boost {
18 : namespace urls {
19 : namespace detail {
20 :
21 : BOOST_URL_CXX14_CONSTEXPR_OR_FORCEINLINE
22 : void
23 : memcpy(
24 : unsigned char* dest,
25 : unsigned char const* src,
26 : std::size_t n) noexcept
27 : {
28 : #if defined(BOOST_URL_HAS_BUILTIN_IS_CONSTANT_EVALUATED)
29 : if (!__builtin_is_constant_evaluated())
30 : {
31 HIT 4498 : std::memcpy(dest, src, n);
32 : }
33 : else
34 : {
35 : for (std::size_t i = 0; i < n; ++i)
36 : {
37 : dest[i] = src[i];
38 : }
39 : }
40 : #elif defined(BOOST_NO_CXX14_CONSTEXPR)
41 : std::memcpy(dest, src, n);
42 : #else
43 : // C++14 constexpr but no way to detect constant
44 : // evaluation: always use the byte loop.
45 : for (std::size_t i = 0; i < n; ++i)
46 : {
47 : dest[i] = src[i];
48 : }
49 : #endif
50 4498 : }
51 :
52 : } // detail
53 : } // urls
54 : } // boost
55 :
56 : #endif
|