mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 09:08:08 +08:00
feat: add static_assert for location/range
to check the container is randomly-accessible
This commit is contained in:
@@ -62,10 +62,14 @@ struct region_base
|
||||
template<typename Container>
|
||||
struct location final : public region_base
|
||||
{
|
||||
static_assert(std::is_same<char, typename Container::value_type>::value,"");
|
||||
using const_iterator = typename Container::const_iterator;
|
||||
using source_ptr = std::shared_ptr<const Container>;
|
||||
|
||||
static_assert(std::is_same<char, typename Container::value_type>::value,"");
|
||||
static_assert(std::is_same<std::random_access_iterator_tag,
|
||||
typename std::iterator_traits<const_iterator>::iterator_category>::value,
|
||||
"container should be randomly accessible");
|
||||
|
||||
location(std::string name, Container cont)
|
||||
: source_(std::make_shared<Container>(std::move(cont))),
|
||||
source_name_(std::move(name)), iter_(source_->cbegin())
|
||||
@@ -139,10 +143,14 @@ struct location final : public region_base
|
||||
template<typename Container>
|
||||
struct region final : public region_base
|
||||
{
|
||||
static_assert(std::is_same<char, typename Container::value_type>::value,"");
|
||||
using const_iterator = typename Container::const_iterator;
|
||||
using source_ptr = std::shared_ptr<const Container>;
|
||||
|
||||
static_assert(std::is_same<char, typename Container::value_type>::value,"");
|
||||
static_assert(std::is_same<std::random_access_iterator_tag,
|
||||
typename std::iterator_traits<const_iterator>::iterator_category>::value,
|
||||
"container should be randomly accessible");
|
||||
|
||||
// delete default constructor. source_ never be null.
|
||||
region() = delete;
|
||||
|
||||
|
Reference in New Issue
Block a user