encoding: disallow bool in Encoder::prependRange etc
bool type is no longer allowed in Encoder::prependRange,
Encoder::appendRange, and encoding::makeBinaryBlock.
refs #4225
Change-Id: I1b3b7d171e8c2baa04dc4ef4617de80e6220e586
diff --git a/src/encoding/block-helpers.hpp b/src/encoding/block-helpers.hpp
index 5634ed6..c66c0b9 100644
--- a/src/encoding/block-helpers.hpp
+++ b/src/encoding/block-helpers.hpp
@@ -26,8 +26,6 @@
#include "encoding-buffer.hpp"
#include "../util/concepts.hpp"
-#include <iterator>
-
namespace ndn {
namespace encoding {
@@ -233,8 +231,6 @@
Block
makeBinaryBlock(uint32_t type, Iterator first, Iterator last)
{
- static_assert(sizeof(typename std::iterator_traits<Iterator>::value_type) == 1, "");
-
using BinaryBlockHelper = typename std::conditional<
std::is_base_of<std::random_access_iterator_tag,
typename std::iterator_traits<Iterator>::iterator_category>::value,
diff --git a/src/encoding/encoder.hpp b/src/encoding/encoder.hpp
index 28b2fa1..06a7ca1 100644
--- a/src/encoding/encoder.hpp
+++ b/src/encoding/encoder.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -22,7 +22,6 @@
#ifndef NDN_ENCODING_ENCODER_HPP
#define NDN_ENCODING_ENCODER_HPP
-#include "../common.hpp"
#include "block.hpp"
namespace ndn {
@@ -140,9 +139,9 @@
appendBlock(const Block& block);
public: // unique interface to the Encoder
- typedef Buffer::value_type value_type;
- typedef Buffer::iterator iterator;
- typedef Buffer::const_iterator const_iterator;
+ using value_type = Buffer::value_type;
+ using iterator = Buffer::iterator;
+ using const_iterator = Buffer::const_iterator;
/**
* @brief Create EncodingBlock from existing block
@@ -316,6 +315,9 @@
inline size_t
Encoder::prependRange(Iterator first, Iterator last)
{
+ using ValueType = typename std::iterator_traits<Iterator>::value_type;
+ static_assert(sizeof(ValueType) == 1 && !std::is_same<ValueType, bool>::value, "");
+
size_t length = std::distance(first, last);
reserveFront(length);
@@ -329,6 +331,9 @@
inline size_t
Encoder::appendRange(Iterator first, Iterator last)
{
+ using ValueType = typename std::iterator_traits<Iterator>::value_type;
+ static_assert(sizeof(ValueType) == 1 && !std::is_same<ValueType, bool>::value, "");
+
size_t length = std::distance(first, last);
reserveBack(length);