From ea13e40889af43af3634ce38f7fc3b0333a05791 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Fri, 12 Apr 2019 18:00:53 +0900 Subject: [PATCH] feat: add static_assert for location/range to check the container is randomly-accessible --- toml/region.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/toml/region.hpp b/toml/region.hpp index 54d9106..7f3f194 100644 --- a/toml/region.hpp +++ b/toml/region.hpp @@ -62,10 +62,14 @@ struct region_base template struct location final : public region_base { - static_assert(std::is_same::value,""); using const_iterator = typename Container::const_iterator; using source_ptr = std::shared_ptr; + static_assert(std::is_same::value,""); + static_assert(std::is_same::iterator_category>::value, + "container should be randomly accessible"); + location(std::string name, Container cont) : source_(std::make_shared(std::move(cont))), source_name_(std::move(name)), iter_(source_->cbegin()) @@ -139,10 +143,14 @@ struct location final : public region_base template struct region final : public region_base { - static_assert(std::is_same::value,""); using const_iterator = typename Container::const_iterator; using source_ptr = std::shared_ptr; + static_assert(std::is_same::value,""); + static_assert(std::is_same::iterator_category>::value, + "container should be randomly accessible"); + // delete default constructor. source_ never be null. region() = delete;