mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-30 06:43:28 +01:00
Remove is_pod trait, and replace with is_standard_layout requirement
This commit is contained in:
parent
35d5aa36c9
commit
951716146f
@ -67,18 +67,14 @@ namespace tools {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T& unwrap(scrubbed<T>& src) { return src; }
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
const T& unwrap(scrubbed<T> const& src) { return src; }
|
||||||
|
|
||||||
template <class T, size_t N>
|
template <class T, size_t N>
|
||||||
using scrubbed_arr = scrubbed<std::array<T, N>>;
|
using scrubbed_arr = scrubbed<std::array<T, N>>;
|
||||||
} // namespace tools
|
} // namespace tools
|
||||||
|
|
||||||
// Partial specialization for std::is_pod<tools::scrubbed<T>> so that it can
|
|
||||||
// pretend to be the containted type in those contexts.
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
template<class t_scrubbee>
|
|
||||||
struct is_pod<tools::scrubbed<t_scrubbee>> {
|
|
||||||
static const bool value = is_pod<t_scrubbee>::value;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -108,7 +108,7 @@ namespace epee
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool has_padding() noexcept
|
constexpr bool has_padding() noexcept
|
||||||
{
|
{
|
||||||
return !std::is_pod<T>::value || alignof(T) != 1;
|
return !std::is_standard_layout<T>() || alignof(T) != 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \return Cast data from `src` as `span<const std::uint8_t>`.
|
//! \return Cast data from `src` as `span<const std::uint8_t>`.
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include "hex.h"
|
#include "hex.h"
|
||||||
|
#include "memwipe.h"
|
||||||
#include "span.h"
|
#include "span.h"
|
||||||
#include "warnings.h"
|
#include "warnings.h"
|
||||||
|
|
||||||
@ -330,7 +331,7 @@ POP_WARNINGS
|
|||||||
template<class t_pod_type>
|
template<class t_pod_type>
|
||||||
std::string pod_to_hex(const t_pod_type& s)
|
std::string pod_to_hex(const t_pod_type& s)
|
||||||
{
|
{
|
||||||
static_assert(std::is_pod<t_pod_type>::value, "expected pod type");
|
static_assert(std::is_standard_layout<t_pod_type>(), "expected standard layout type");
|
||||||
return to_hex::string(as_byte_span(s));
|
return to_hex::string(as_byte_span(s));
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -351,6 +352,12 @@ POP_WARNINGS
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
template<class t_pod_type>
|
||||||
|
bool hex_to_pod(const std::string& hex_str, tools::scrubbed<t_pod_type>& s)
|
||||||
|
{
|
||||||
|
return hex_to_pod(hex_str, unwrap(s));
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
bool validate_hex(uint64_t length, const std::string& str);
|
bool validate_hex(uint64_t length, const std::string& str);
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
inline std::string get_extension(const std::string& str)
|
inline std::string get_extension(const std::string& str)
|
||||||
|
Loading…
Reference in New Issue
Block a user