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