Added thirdparty: boost library

This commit is contained in:
Viacheslav Demydiuk
2024-01-06 19:55:56 +02:00
parent bf49f439e1
commit bccd1e7051
15683 changed files with 3239840 additions and 0 deletions
+189
View File
@@ -0,0 +1,189 @@
//
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// 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)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_GRAMMAR_DETAIL_CHARSET_HPP
#define BOOST_URL_GRAMMAR_DETAIL_CHARSET_HPP
#include <boost/core/bit.hpp>
#include <type_traits>
#ifdef BOOST_URL_USE_SSE2
# include <emmintrin.h>
# include <xmmintrin.h>
# ifdef _MSC_VER
# include <intrin.h>
# endif
#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4127) // conditional expression is constant
#endif
namespace boost {
namespace urls {
namespace grammar {
namespace detail {
template<class T, class = void>
struct has_find_if : std::false_type {};
template<class T>
struct has_find_if<T, void_t<
decltype(
std::declval<char const*&>() =
std::declval<T const&>().find_if(
std::declval<char const*>(),
std::declval<char const*>())
)>> : std::true_type
{
};
template<class T, class = void>
struct has_find_if_not : std::false_type {};
template<class T>
struct has_find_if_not<T, void_t<
decltype(
std::declval<char const*&>() =
std::declval<T const&>().find_if_not(
std::declval<char const*>(),
std::declval<char const*>())
)>> : std::true_type
{
};
template<class Pred>
char const*
find_if(
char const* first,
char const* const last,
Pred const& pred,
std::false_type) noexcept
{
while(first != last)
{
if(pred(*first))
break;
++first;
}
return first;
}
template<class Pred>
char const*
find_if(
char const* first,
char const* const last,
Pred const& pred,
std::true_type) noexcept
{
return pred.find_if(
first, last);
}
template<class Pred>
char const*
find_if_not(
char const* first,
char const* const last,
Pred const& pred,
std::false_type) noexcept
{
while(first != last)
{
if(! pred(*first))
break;
++first;
}
return first;
}
template<class Pred>
char const*
find_if_not(
char const* first,
char const* const last,
Pred const& pred,
std::true_type) noexcept
{
return pred.find_if_not(
first, last);
}
#ifdef BOOST_URL_USE_SSE2
// by Peter Dimov
template<class Pred>
char const*
find_if_pred(
Pred const& pred,
char const* first,
char const* last ) noexcept
{
while( last - first >= 16 )
{
unsigned char r[ 16 ] = {};
for( int i = 0; i < 16; ++i )
r[ i ] = pred( first[ i ] )? 0xFF: 0x00;
__m128i r2 = _mm_loadu_si128( (__m128i const*)r );
unsigned r3 = _mm_movemask_epi8( r2 );
if( r3 )
return first + boost::core::countr_zero( r3 );
first += 16;
}
while(
first != last &&
! pred(*first))
{
++first;
}
return first;
}
// by Peter Dimov
template<class Pred>
char const*
find_if_not_pred(
Pred const& pred,
char const* first,
char const* last ) noexcept
{
while( last - first >= 16 )
{
unsigned char r[ 16 ] = {};
for( int i = 0; i < 16; ++i )
r[ i ] = pred( first[ i ] )? 0x00: 0xFF;
__m128i r2 = _mm_loadu_si128( (__m128i const*)r );
unsigned r3 = _mm_movemask_epi8( r2 );
if( r3 )
return first + boost::core::countr_zero( r3 );
first += 16;
}
while(
first != last &&
pred(*first))
{
++first;
}
return first;
}
#endif
} // detail
} // grammar
} // urls
} // boost
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif
+179
View File
@@ -0,0 +1,179 @@
//
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
//
// 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)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_GRAMMAR_DETAIL_CI_STRING_HPP
#define BOOST_URL_GRAMMAR_DETAIL_CI_STRING_HPP
#include <boost/core/detail/string_view.hpp>
#include <boost/assert.hpp>
#include <cstdint>
#include <iterator>
#include <type_traits>
namespace boost {
namespace urls {
namespace grammar {
namespace detail {
template<class T, class = void>
struct is_char_iter : std::false_type {};
template<class T>
struct is_char_iter<T, void_t<
decltype(std::declval<char&>() =
*std::declval<T const&>()),
decltype(std::declval<T&>() =
++std::declval<T&>()),
decltype(std::declval<bool&>() =
std::declval<T const&>() ==
std::declval<T const&>())
> > : std::integral_constant<bool,
std::is_copy_constructible<T>::value>
{
};
template<class T, class = void>
struct is_char_range : std::false_type {};
template<class T>
struct is_char_range<T, void_t<
decltype(std::declval<T const&>().begin()),
decltype(std::declval<T const&>().end())
> > : std::integral_constant<bool,
is_char_iter<decltype(
std::declval<T const&>(
).begin())>::value &&
is_char_iter<decltype(
std::declval<T const&>(
).end())>::value>
{
};
template<class T>
struct type_id_impl
{
static
constexpr
char cid = 0;
};
template<class T>
constexpr
char
type_id_impl<T>::cid;
template<class T>
constexpr
std::uintptr_t
type_id() noexcept
{
return std::uintptr_t(
&type_id_impl<T>::cid);
}
//------------------------------------------------
constexpr
char
to_lower(char c) noexcept
{
return
(c >= 'A' &&
c <= 'Z')
? c + 'a' - 'A'
: c;
}
constexpr
char
to_upper(char c) noexcept
{
return
(c >= 'a' &&
c <= 'z')
? c - ('a' - 'A')
: c;
}
//------------------------------------------------
template<class S0, class S1>
auto
ci_is_equal(
S0 const& s0,
S1 const& s1) ->
typename std::enable_if<
! std::is_convertible<
S0, core::string_view>::value ||
! std::is_convertible<
S1, core::string_view>::value,
bool>::type
{
/* If you get a compile error here, it
means that a range you passed does
not meet the requirements stated
in the documentation.
*/
static_assert(
is_char_range<S0>::value,
"Type requirements not met");
static_assert(
is_char_range<S1>::value,
"Type requirements not met");
// Arguments are sorted by type to
// reduce the number of function
// template instantiations. This
// works because:
//
// ci_is_equal(s0,s1) == ci_is_equal(s1,s0)
//
BOOST_ASSERT(
detail::type_id<S0>() <=
detail::type_id<S1>());
auto it0 = s0.begin();
auto it1 = s1.begin();
auto const end0 = s0.end();
auto const end1 = s1.end();
for(;;)
{
if(it0 == end0)
return it1 == end1;
if(it1 == end1)
return false;
if( to_lower(*it0) !=
to_lower(*it1))
return false;
++it0;
++it1;
}
}
//------------------------------------------------
BOOST_URL_DECL
bool
ci_is_equal(
core::string_view s0,
core::string_view s1) noexcept;
BOOST_URL_DECL
bool
ci_is_less(
core::string_view s0,
core::string_view s1) noexcept;
} // detail
} // grammar
} // urls
} // boost
#endif
+102
View File
@@ -0,0 +1,102 @@
//
// Copyright (c) 2022 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_GRAMMAR_DETAIL_RECYCLED_HPP
#define BOOST_URL_GRAMMAR_DETAIL_RECYCLED_HPP
#include <utility>
namespace boost {
namespace urls {
namespace grammar {
namespace detail {
template<
std::size_t Size,
std::size_t Align>
struct aligned_storage_impl
{
void* addr() noexcept
{
return buf_;
}
void const* addr() const noexcept
{
return buf_;
}
private:
alignas(Align)
unsigned char buf_[Size];
};
constexpr
std::size_t
nearest_pow2(
std::size_t x,
std::size_t f = 0) noexcept
{
return
(f <= (std::size_t(-1)/2))
? ( x <= f
? f
: nearest_pow2(x, 2 * f))
: x;
}
//------------------------------------------------
BOOST_URL_DECL
void
recycled_add_impl(
std::size_t) noexcept;
BOOST_URL_DECL
void
recycled_remove_impl(
std::size_t) noexcept;
#ifdef BOOST_URL_REPORT
inline
void
recycled_add(
std::size_t n) noexcept
{
recycled_add_impl(n);
}
inline
void
recycled_remove(
std::size_t n) noexcept
{
recycled_remove_impl(n);
}
#else
inline void recycled_add(
std::size_t) noexcept
{
}
inline void recycled_remove(
std::size_t) noexcept
{
}
#endif
} // detail
} // grammar
} // urls
} // boost
#endif
+212
View File
@@ -0,0 +1,212 @@
//
// Copyright (c) 2016-2019 Damian Jarek (damian dot jarek93 at gmail dot com)
// Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// 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)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_URL_GRAMMAR_DETAIL_TUPLE_HPP
#define BOOST_URL_GRAMMAR_DETAIL_TUPLE_HPP
#include <boost/url/detail/config.hpp>
#include <boost/url/error_types.hpp>
#include <boost/core/empty_value.hpp>
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/function.hpp>
#include <boost/mp11/integer_sequence.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/copy_cv.hpp>
#include <cstdlib>
#include <utility>
#ifndef BOOST_URL_TUPLE_EBO
// VFALCO No idea what causes it or how to fix it
// https://devblogs.microsoft.com/cppblog/optimizing-the-layout-of-empty-base-classes-in-vs2015-update-2-3/
#ifdef BOOST_MSVC
#define BOOST_URL_TUPLE_EBO 0
#else
#define BOOST_URL_TUPLE_EBO 1
#endif
#endif
namespace boost {
namespace urls {
namespace grammar {
namespace detail {
#if BOOST_URL_TUPLE_EBO
template<std::size_t I, class T>
struct tuple_element_impl
: empty_value<T>
{
constexpr
tuple_element_impl(T const& t)
: empty_value<T>(
empty_init, t)
{
}
constexpr
tuple_element_impl(T&& t)
: empty_value<T>(
empty_init,
std::move(t))
{
}
};
#else
template<std::size_t I, class T>
struct tuple_element_impl
{
T t_;
constexpr
tuple_element_impl(T const& t)
: t_(t)
{
}
constexpr
tuple_element_impl(T&& t)
: t_(std::move(t))
{
}
constexpr
T&
get() noexcept
{
return t_;
}
constexpr
T const&
get() const noexcept
{
return t_;
}
};
#endif
template<std::size_t I, class T>
struct tuple_element_impl<I, T&>
{
T& t;
constexpr
tuple_element_impl(T& t_)
: t(t_)
{
}
T&
get() const noexcept
{
return t;
}
};
template<class... Ts>
struct tuple_impl;
template<class... Ts, std::size_t... Is>
struct tuple_impl<
mp11::index_sequence<Is...>, Ts...>
: tuple_element_impl<Is, Ts>...
{
template<class... Us>
constexpr
explicit
tuple_impl(Us&&... us)
: tuple_element_impl<Is, Ts>(
std::forward<Us>(us))...
{
}
};
template<class... Ts>
struct tuple
: tuple_impl<
mp11::index_sequence_for<Ts...>, Ts...>
{
template<class... Us,
typename std::enable_if<
mp11::mp_bool<
mp11::mp_all<std::is_constructible<
Ts, Us>...>::value &&
! mp11::mp_all<std::is_convertible<
Us, Ts>...>::value>::value,
int>::type = 0
>
constexpr
explicit
tuple(Us&&... us) noexcept
: tuple_impl<mp11::index_sequence_for<
Ts...>, Ts...>{std::forward<Us>(us)...}
{
}
template<class... Us,
typename std::enable_if<
mp11::mp_all<std::is_convertible<
Us, Ts>...>::value,
int>::type = 0
>
constexpr
tuple(Us&&... us) noexcept
: tuple_impl<mp11::index_sequence_for<
Ts...>, Ts...>{std::forward<Us>(us)...}
{
}
};
//------------------------------------------------
template<std::size_t I, class T>
constexpr
T&
get(tuple_element_impl<I, T>& te)
{
return te.get();
}
template<std::size_t I, class T>
constexpr
T const&
get(tuple_element_impl<I, T> const& te)
{
return te.get();
}
template<std::size_t I, class T>
constexpr
T&&
get(tuple_element_impl<I, T>&& te)
{
return std::move(te.get());
}
template<std::size_t I, class T>
constexpr
T&
get(tuple_element_impl<I, T&>&& te)
{
return te.get();
}
template<std::size_t I, class T>
using tuple_element =
typename boost::copy_cv<
mp11::mp_at_c<typename
remove_cv<T>::type,
I>, T>::type;
} // detail
} // grammar
} // urls
} // boost
#endif