ソースを参照

2010-03-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Added vbegin() and vend() for fixed sized array.
	* src/DownloadHandlerConstants.cc
	* src/FeatureConfig.cc
	* src/OptionHandlerFactory.cc
	* src/ServerStat.cc
	* src/TimeA2.cc
	* src/XmlRpcMethod.cc
	* src/array_fun.h
	* src/download_helper.cc
	* src/messageDigest.cc
	* src/util.cc
	* test/BittorrentHelperTest.cc
	* test/DHTRoutingTableDeserializerTest.cc
	* test/DHTRoutingTableSerializerTest.cc
	* test/DefaultBtAnnounceTest.cc
	* test/DefaultBtProgressInfoFileTest.cc
	* test/DownloadContextTest.cc
	* test/DownloadHelperTest.cc
	* test/FeatureConfigTest.cc
	* test/FeedbackURISelectorTest.cc
	* test/HttpRequestTest.cc
	* test/InOrderURISelectorTest.cc
	* test/MSEHandshakeTest.cc
	* test/MultiDiskAdaptorTest.cc
	* test/MultiFileAllocationIteratorTest.cc
	* test/PriorityPieceSelectorTest.cc
	* test/RequestGroupManTest.cc
	* test/UtilTest.cc
	* test/XmlRpcMethodTest.cc
	* test/a2algoTest.cc
	* test/array_funTest.cc
Tatsuhiro Tsujikawa 15 年 前
コミット
f15d22b619

+ 34 - 0
ChangeLog

@@ -1,3 +1,37 @@
+2010-03-25  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Added vbegin() and vend() for fixed sized array.
+	* src/DownloadHandlerConstants.cc
+	* src/FeatureConfig.cc
+	* src/OptionHandlerFactory.cc
+	* src/ServerStat.cc
+	* src/TimeA2.cc
+	* src/XmlRpcMethod.cc
+	* src/array_fun.h
+	* src/download_helper.cc
+	* src/messageDigest.cc
+	* src/util.cc
+	* test/BittorrentHelperTest.cc
+	* test/DHTRoutingTableDeserializerTest.cc
+	* test/DHTRoutingTableSerializerTest.cc
+	* test/DefaultBtAnnounceTest.cc
+	* test/DefaultBtProgressInfoFileTest.cc
+	* test/DownloadContextTest.cc
+	* test/DownloadHelperTest.cc
+	* test/FeatureConfigTest.cc
+	* test/FeedbackURISelectorTest.cc
+	* test/HttpRequestTest.cc
+	* test/InOrderURISelectorTest.cc
+	* test/MSEHandshakeTest.cc
+	* test/MultiDiskAdaptorTest.cc
+	* test/MultiFileAllocationIteratorTest.cc
+	* test/PriorityPieceSelectorTest.cc
+	* test/RequestGroupManTest.cc
+	* test/UtilTest.cc
+	* test/XmlRpcMethodTest.cc
+	* test/a2algoTest.cc
+	* test/array_funTest.cc
+
 2010-03-24  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Simplified code using lastByteMask

+ 4 - 8
src/DownloadHandlerConstants.cc

@@ -57,8 +57,7 @@ const std::vector<std::string>&
 DownloadHandlerConstants::getMetalinkExtensions()
 {
   static const std::vector<std::string> l
-    (&METALINK_EXTENSIONS[0],
-     &METALINK_EXTENSIONS[arrayLength(METALINK_EXTENSIONS)]);
+    (vbegin(METALINK_EXTENSIONS), vend(METALINK_EXTENSIONS));
   return l;
 }
 
@@ -66,24 +65,21 @@ const std::vector<std::string>&
 DownloadHandlerConstants::getMetalinkContentTypes()
 {
   static const std::vector<std::string> l
-    (&METALINK_CONTENT_TYPES[0],
-     &METALINK_CONTENT_TYPES[arrayLength(METALINK_CONTENT_TYPES)]);
+    (vbegin(METALINK_CONTENT_TYPES), vend(METALINK_CONTENT_TYPES));
   return l;
 }
 
 const std::vector<std::string>& DownloadHandlerConstants::getBtExtensions()
 {
   static const std::vector<std::string> l
-    (&BT_EXTENSIONS[0],
-     &BT_EXTENSIONS[arrayLength(BT_EXTENSIONS)]);
+    (vbegin(BT_EXTENSIONS), vend(BT_EXTENSIONS));
   return l;
 }
 
 const std::vector<std::string>& DownloadHandlerConstants::getBtContentTypes()
 {
   static const std::vector<std::string> l
-    (&BT_CONTENT_TYPES[0],
-     &BT_CONTENT_TYPES[arrayLength(BT_CONTENT_TYPES)]);
+    (vbegin(BT_CONTENT_TYPES), vend(BT_CONTENT_TYPES));
   return l;
 }
 

+ 1 - 1
src/FeatureConfig.cc

@@ -117,7 +117,7 @@ FeatureConfig::FeatureConfig() {
     FeatureMap::value_type(FEATURE_FIREFOX3_COOKIE, FIREFOX3_COOKIE_ENABLED),
   };
 
-  _features.insert(&featureArray[0], &featureArray[arrayLength(featureArray)]);
+  _features.insert(vbegin(featureArray), vend(featureArray));
 }
 
 SharedHandle<FeatureConfig> FeatureConfig::getInstance()

+ 4 - 5
src/OptionHandlerFactory.cc

@@ -210,7 +210,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
                                     V_SELECT,
 #endif // !HAVE_EPOLL
                                     std::vector<std::string>
-                                    (&params[0],&params[arrayLength(params)])));
+                                    (vbegin(params), vend(params))));
     op->addTag(TAG_ADVANCED);
     handlers.push_back(op);
   }
@@ -286,8 +286,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
                                     TEXT_LOG_LEVEL,
                                     V_DEBUG,
                                     std::vector<std::string>
-                                    (&params[0],
-                                     &params[arrayLength(params)])));
+                                    (vbegin(params), vend(params))));
     op->addTag(TAG_ADVANCED);
     handlers.push_back(op);
   }
@@ -649,7 +648,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
                                     TEXT_URI_SELECTOR,
                                     V_FEEDBACK,
                                     std::vector<std::string>
-                                    (&params[0], &params[arrayLength(params)])));
+                                    (vbegin(params), vend(params))));
     op->addTag(TAG_FTP);
     op->addTag(TAG_HTTP);
     handlers.push_back(op);
@@ -1379,7 +1378,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
                                     TEXT_METALINK_PREFERRED_PROTOCOL,
                                     V_NONE,
                                     std::vector<std::string>
-                                    (&params[0], &params[arrayLength(params)])));
+                                    (vbegin(params), vend(params))));
     op->addTag(TAG_METALINK);
     handlers.push_back(op);
   }

+ 3 - 5
src/ServerStat.cc

@@ -167,13 +167,11 @@ void ServerStat::setStatus(STATUS status)
 
 void ServerStat::setStatus(const std::string& status)
 {
-  size_t len = arrayLength(STATUS_STRING);
-  const std::string* p = std::find(&STATUS_STRING[0],
-                                   &STATUS_STRING[len],
+  const std::string* p = std::find(vbegin(STATUS_STRING), vend(STATUS_STRING),
                                    status);
-  if(p != &STATUS_STRING[len]) {
+  if(p != vend(STATUS_STRING)) {
     _status = static_cast<STATUS>(ServerStat::OK+
-                                  std::distance(&STATUS_STRING[0], p));
+                                  std::distance(vbegin(STATUS_STRING), p));
   }
 }
 

+ 1 - 1
src/TimeA2.cc

@@ -212,7 +212,7 @@ Time Time::parseHTTPDate(const std::string& datetime)
     &parseRFC850Ext,
   };
   for(Time (**funcsp)(const std::string&) = &funcs[0];
-      funcsp != &funcs[arrayLength(funcs)]; ++funcsp) {
+      funcsp != vend(funcs); ++funcsp) {
     Time t = (*funcsp)(datetime);
     if(t.good()) {
       return t;

+ 2 - 4
src/XmlRpcMethod.cc

@@ -147,8 +147,7 @@ const std::set<std::string>& listChangeableOptions()
     PREF_MAX_DOWNLOAD_LIMIT,
     PREF_MAX_UPLOAD_LIMIT
   };
-  static std::set<std::string> options
-    (&OPTIONS[0], &OPTIONS[arrayLength(OPTIONS)]);
+  static std::set<std::string> options(vbegin(OPTIONS), vend(OPTIONS));
   return options;
 }
 
@@ -173,8 +172,7 @@ const std::set<std::string>& listChangeableGlobalOptions()
     PREF_MAX_OVERALL_DOWNLOAD_LIMIT,
     PREF_MAX_CONCURRENT_DOWNLOADS,
   };
-  static std::set<std::string> options
-    (&OPTIONS[0], &OPTIONS[arrayLength(OPTIONS)]);
+  static std::set<std::string> options(vbegin(OPTIONS), vend(OPTIONS));
   return options;
 }
 

+ 12 - 0
src/array_fun.h

@@ -57,6 +57,18 @@ size_t arrayLength(T (&a)[0u])
   return 0;
 }
 
+template<typename T, size_t N>
+T* vbegin(T (&a)[N])
+{
+  return a;
+}
+
+template<typename T, size_t N>
+T* vend(T (&a)[N])
+{
+  return a+arrayLength(a);
+}
+
 template<typename T>
 class array_ptr {
 private:

+ 1 - 3
src/download_helper.cc

@@ -155,9 +155,7 @@ const std::set<std::string>& listRequestOptions()
     PREF_REALTIME_CHUNK_CHECKSUM
   };
   static std::set<std::string> requestOptions
-    (&REQUEST_OPTIONS[0],
-     &REQUEST_OPTIONS[arrayLength(REQUEST_OPTIONS)]);;
-
+    (vbegin(REQUEST_OPTIONS), vend(REQUEST_OPTIONS));
   return requestOptions;
 }
 

+ 1 - 2
src/messageDigest.cc

@@ -89,8 +89,7 @@ static const DigestAlgoMap& getDigestAlgos()
     ("sha256", DigestAlgoEntry(GCRY_MD_SHA256, STRENGTH_SHA_256)),
 #endif // HAVE_LIBGCRYPT
   };
-  static const DigestAlgoMap algomap
-    (&digests[0], &digests[arrayLength(digests)]);  
+  static const DigestAlgoMap algomap(vbegin(digests), vend(digests));
   return algomap;
 }
 

+ 6 - 12
src/util.cc

@@ -256,16 +256,14 @@ bool inRFC3986ReservedChars(const char c)
     ':' , '/' , '?' , '#' , '[' , ']' , '@',
     '!' , '$' , '&' , '\'' , '(' , ')',
     '*' , '+' , ',' , ';' , '=' };
-  return std::find(&reserved[0], &reserved[arrayLength(reserved)], c) !=
-    &reserved[arrayLength(reserved)];
+  return std::find(vbegin(reserved), vend(reserved), c) != vend(reserved);
 }
 
 bool inRFC3986UnreservedChars(const char c)
 {
   static const char unreserved[] = { '-', '.', '_', '~' };
   return isAlpha(c) || isDigit(c) ||
-    std::find(&unreserved[0], &unreserved[arrayLength(unreserved)], c) !=
-    &unreserved[arrayLength(unreserved)];
+    std::find(vbegin(unreserved), vend(unreserved), c) != vend(unreserved);
 }
 
 bool inRFC2978MIMECharset(const char c)
@@ -276,8 +274,7 @@ bool inRFC2978MIMECharset(const char c)
     '`', '{', '}', '~'
   };
   return isAlpha(c) || isDigit(c) ||
-    std::find(&chars[0], &chars[arrayLength(chars)], c) !=
-    &chars[arrayLength(chars)];
+    std::find(vbegin(chars), vend(chars), c) != vend(chars);
 }
 
 bool inRFC2616HttpToken(const char c)
@@ -287,8 +284,7 @@ bool inRFC2616HttpToken(const char c)
     '^', '_', '`', '|', '~'
   };
   return isAlpha(c) || isDigit(c) ||
-    std::find(&chars[0], &chars[arrayLength(chars)], c) !=
-    &chars[arrayLength(chars)];
+    std::find(vbegin(chars), vend(chars), c) != vend(chars);
 }
 
 std::string percentEncode(const unsigned char* target, size_t len) {
@@ -1245,10 +1241,8 @@ public:
     // We don't escape '/' because we use it as a path separator.
     static const char WIN_INVALID_PATH_CHARS[] =
       { '"', '*', ':', '<', '>', '?', '\\', '|' };
-    if(std::find(&WIN_INVALID_PATH_CHARS[0],
-                 &WIN_INVALID_PATH_CHARS[arrayLength(WIN_INVALID_PATH_CHARS)],
-                 c) !=
-       &WIN_INVALID_PATH_CHARS[arrayLength(WIN_INVALID_PATH_CHARS)]) {
+    if(std::find(vbegin(WIN_INVALID_PATH_CHARS), vend(WIN_INVALID_PATH_CHARS),
+                 c) != vend(WIN_INVALID_PATH_CHARS)) {
       return _repChar;
     }
 #endif // __MINGW32__

+ 3 - 3
test/BittorrentHelperTest.cc

@@ -317,7 +317,7 @@ void BittorrentHelperTest::testComputeFastSet()
     std::vector<size_t> fastSet;
     computeFastSet(fastSet, ipaddr, numPieces, infoHash, fastSetSize);
     size_t ans[] = { 686, 459, 278, 200, 404, 834, 64, 203, 760, 950 };
-    std::vector<size_t> ansSet(&ans[0], &ans[arrayLength(ans)]);
+    std::vector<size_t> ansSet(vbegin(ans), vend(ans));
     CPPUNIT_ASSERT(std::equal(fastSet.begin(), fastSet.end(), ansSet.begin()));
   }
   ipaddr = "10.0.0.1";
@@ -325,7 +325,7 @@ void BittorrentHelperTest::testComputeFastSet()
     std::vector<size_t> fastSet;
     computeFastSet(fastSet, ipaddr, numPieces, infoHash, fastSetSize);
     size_t ans[] = { 568, 188, 466, 452, 550, 662, 109, 226, 398, 11 };
-    std::vector<size_t> ansSet(&ans[0], &ans[arrayLength(ans)]);
+    std::vector<size_t> ansSet(vbegin(ans), vend(ans));
     CPPUNIT_ASSERT(std::equal(fastSet.begin(), fastSet.end(), ansSet.begin()));
   }
   // See when pieces < fastSetSize
@@ -334,7 +334,7 @@ void BittorrentHelperTest::testComputeFastSet()
     std::vector<size_t> fastSet;
     computeFastSet(fastSet, ipaddr, numPieces, infoHash, fastSetSize);
     size_t ans[] = { 8, 6, 7, 5, 1, 4, 0, 2, 3 };
-    std::vector<size_t> ansSet(&ans[0], &ans[arrayLength(ans)]);
+    std::vector<size_t> ansSet(vbegin(ans), vend(ans));
     CPPUNIT_ASSERT(std::equal(fastSet.begin(), fastSet.end(), ansSet.begin()));
   }
 }

+ 1 - 2
test/DHTRoutingTableDeserializerTest.cc

@@ -43,8 +43,7 @@ void DHTRoutingTableDeserializerTest::testDeserialize()
     nodesSrc[i]->setPort(6881+i);
   }
   nodesSrc[1]->setIPAddress("non-numerical-name");
-  std::vector<SharedHandle<DHTNode> > nodes
-    (&nodesSrc[0], &nodesSrc[arrayLength(nodesSrc)]);
+  std::vector<SharedHandle<DHTNode> > nodes(vbegin(nodesSrc), vend(nodesSrc));
   
   DHTRoutingTableSerializer s;
   s.setLocalNode(localNode);

+ 8 - 6
test/DHTRoutingTableSerializerTest.cc

@@ -1,4 +1,11 @@
 #include "DHTRoutingTableSerializer.h"
+
+#include <cstring>
+#include <sstream>
+#include <iostream>
+
+#include <cppunit/extensions/HelperMacros.h>
+
 #include "Exception.h"
 #include "util.h"
 #include "DHTNode.h"
@@ -6,10 +13,6 @@
 #include "DHTConstants.h"
 #include "bittorrent_helper.h"
 #include "a2netcompat.h"
-#include <cstring>
-#include <sstream>
-#include <iostream>
-#include <cppunit/extensions/HelperMacros.h>
 
 namespace aria2 {
 
@@ -40,8 +43,7 @@ void DHTRoutingTableSerializerTest::testSerialize()
     nodesSrc[i]->setPort(6881+i);
   }
   nodesSrc[1]->setIPAddress("non-numerical-name");
-  std::vector<SharedHandle<DHTNode> > nodes
-    (&nodesSrc[0], &nodesSrc[arrayLength(nodesSrc)]);
+  std::vector<SharedHandle<DHTNode> > nodes(vbegin(nodesSrc), vend(nodesSrc));
   
   DHTRoutingTableSerializer s;
   s.setLocalNode(localNode);

+ 3 - 3
test/DefaultBtAnnounceTest.cc

@@ -58,7 +58,7 @@ public:
     _dctx.reset(new DownloadContext(pieceLength, totalLength));
     BDE torrentAttrs = BDE::dict();
     torrentAttrs[bittorrent::INFO_HASH] =
-      std::string(&infoHash[0], &infoHash[arrayLength(infoHash)]);
+      std::string(vbegin(infoHash), vend(infoHash));
     _dctx->setAttribute(bittorrent::BITTORRENT, torrentAttrs);
     bittorrent::setStaticPeerId(peerId);
 
@@ -282,7 +282,7 @@ void DefaultBtAnnounceTest::testURLOrderInStoppedEvent()
                          "http://localhost2/announce" };
 
   BDE announceList = BDE::list();
-  announceList << createAnnounceTier(&urls[0], &urls[arrayLength(urls)]);
+  announceList << createAnnounceTier(vbegin(urls), vend(urls));
   setAnnounceList(_dctx, announceList);
 
   DefaultBtAnnounce btAnnounce(_dctx, _option);
@@ -312,7 +312,7 @@ void DefaultBtAnnounceTest::testURLOrderInCompletedEvent()
                          "http://localhost2/announce" };
 
   BDE announceList = BDE::list();
-  announceList << createAnnounceTier(&urls[0], &urls[arrayLength(urls)]);
+  announceList << createAnnounceTier(vbegin(urls), vend(urls));
   setAnnounceList(_dctx, announceList);
 
   DefaultBtAnnounce btAnnounce(_dctx, _option);

+ 2 - 3
test/DefaultBtProgressInfoFileTest.cc

@@ -72,14 +72,13 @@ public:
     _dctx.reset(new DownloadContext());
     BDE torrentAttrs = BDE::dict();
     torrentAttrs[bittorrent::INFO_HASH] =
-      std::string(&infoHash[0], &infoHash[arrayLength(infoHash)]);
+      std::string(vbegin(infoHash), vend(infoHash));
     _dctx->setAttribute(bittorrent::BITTORRENT, torrentAttrs);
     _dctx->setDir(_option->get(PREF_DIR));
     const SharedHandle<FileEntry> fileEntries[] = {
       SharedHandle<FileEntry>(new FileEntry("/path/to/file",totalLength,0))
     };
-    _dctx->setFileEntries(&fileEntries[0],
-                          &fileEntries[arrayLength(fileEntries)]);
+    _dctx->setFileEntries(vbegin(fileEntries), vend(fileEntries));
     _dctx->setPieceLength(pieceLength);
     _peerStorage.reset(new MockPeerStorage());
     _btRuntime.reset(new BtRuntime());

+ 1 - 2
test/DownloadContextTest.cc

@@ -39,8 +39,7 @@ void DownloadContextTest::testFindFileEntryByOffset()
       SharedHandle<FileEntry>(new FileEntry("file5",3000,3000)),
       SharedHandle<FileEntry>(new FileEntry("file6",0,6000))
     };
-  ctx.setFileEntries(&fileEntries[0],
-                     &fileEntries[arrayLength(fileEntries)]);
+  ctx.setFileEntries(vbegin(fileEntries), vend(fileEntries));
 
   CPPUNIT_ASSERT_EQUAL(std::string("file1"),
                        ctx.findFileEntryByOffset(0)->getPath());

+ 5 - 5
test/DownloadHelperTest.cc

@@ -69,7 +69,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri()
     "http://bravo/file",
     "http://charlie/file"
   };
-  std::vector<std::string> uris(&array[0], &array[arrayLength(array)]);
+  std::vector<std::string> uris(vbegin(array), vend(array));
   _option->put(PREF_SPLIT, "3");
   _option->put(PREF_DIR, "/tmp");
   _option->put(PREF_OUT, "file.out");
@@ -157,7 +157,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_parameterized()
     "http://{alpha, bravo}/file",
     "http://charlie/file"
   };
-  std::vector<std::string> uris(&array[0], &array[arrayLength(array)]);
+  std::vector<std::string> uris(vbegin(array), vend(array));
   _option->put(PREF_SPLIT, "3");
   _option->put(PREF_DIR, "/tmp");
   _option->put(PREF_OUT, "file.out");
@@ -193,7 +193,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_BitTorrent()
     "http://bravo/file",
     "http://charlie/file"
   };
-  std::vector<std::string> uris(&array[0], &array[arrayLength(array)]);
+  std::vector<std::string> uris(vbegin(array), vend(array));
   _option->put(PREF_SPLIT, "3");
   _option->put(PREF_DIR, "/tmp");
   _option->put(PREF_OUT, "file.out");
@@ -241,7 +241,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink()
     "http://charlie/file",
     "test.xml"
   };
-  std::vector<std::string> uris(&array[0], &array[arrayLength(array)]);
+  std::vector<std::string> uris(vbegin(array), vend(array));
   _option->put(PREF_SPLIT, "3");
   _option->put(PREF_METALINK_SERVERS, "2");
   _option->put(PREF_DIR, "/tmp");
@@ -329,7 +329,7 @@ void DownloadHelperTest::testCreateRequestGroupForBitTorrent()
     "http://charlie/file"
   };
 
-  std::vector<std::string> auxURIs(&array[0], &array[arrayLength(array)]);
+  std::vector<std::string> auxURIs(vbegin(array), vend(array));
   _option->put(PREF_SPLIT, "5");
   _option->put(PREF_TORRENT_FILE, "test.torrent");
   _option->put(PREF_DIR, "/tmp");

+ 1 - 1
test/FeatureConfigTest.cc

@@ -89,7 +89,7 @@ void FeatureConfigTest::testFeatureSummary() {
 
   std::string featuresString;
   const std::string delim(", ");
-  std::for_each(&features[0], &features[arrayLength(features)],
+  std::for_each(vbegin(features), vend(features),
                 StringAppend(featuresString, delim));
   // USE util::trimSelf(featureString);
   featuresString = util::trim(featuresString, delim);

+ 1 - 1
test/FeedbackURISelectorTest.cc

@@ -34,7 +34,7 @@ public:
       "http://bravo/file"
     };
     std::vector<std::string> uris;
-    uris.assign(&urisSrc[0], &urisSrc[arrayLength(urisSrc)]);
+    uris.assign(vbegin(urisSrc), vend(urisSrc));
     
     _fileEntry.setUris(uris);
 

+ 1 - 2
test/HttpRequestTest.cc

@@ -690,8 +690,7 @@ void HttpRequestTest::testAddAcceptType()
   httpRequest.disableContentEncoding();
   httpRequest.setRequest(request);
   httpRequest.setAuthConfigFactory(_authConfigFactory, _option.get());
-  httpRequest.addAcceptType(&acceptTypes[0],
-                            &acceptTypes[arrayLength(acceptTypes)]);
+  httpRequest.addAcceptType(vbegin(acceptTypes), vend(acceptTypes));
 
   std::string expectedText =
     "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"

+ 1 - 1
test/InOrderURISelectorTest.cc

@@ -28,7 +28,7 @@ public:
       "http://bravo/file"
     };
     std::vector<std::string> uris;
-    uris.assign(&urisSrc[0], &urisSrc[arrayLength(urisSrc)]);
+    uris.assign(vbegin(urisSrc), vend(urisSrc));
     
     _fileEntry.setUris(uris);
 

+ 1 - 1
test/MSEHandshakeTest.cc

@@ -35,7 +35,7 @@ public:
     memset(infoHash, 0, sizeof(infoHash));
     BDE torrentAttrs = BDE::dict();
     torrentAttrs[bittorrent::INFO_HASH] =
-      std::string(&infoHash[0], &infoHash[arrayLength(infoHash)]);
+      std::string(vbegin(infoHash), vend(infoHash));
     _dctx->setAttribute(bittorrent::BITTORRENT, torrentAttrs);
   }
 

+ 4 - 5
test/MultiDiskAdaptorTest.cc

@@ -68,8 +68,7 @@ std::vector<SharedHandle<FileEntry> > createEntries() {
   //                         *** file6
   //                            |file7
   //                            ** file8
-  std::vector<SharedHandle<FileEntry> > entries(&array[0],
-                                                &array[arrayLength(array)]);
+  std::vector<SharedHandle<FileEntry> > entries(vbegin(array), vend(array));
   for(std::vector<SharedHandle<FileEntry> >::const_iterator i = entries.begin();
       i != entries.end(); ++i) {
     File((*i)->getPath()).remove();
@@ -376,7 +375,7 @@ void MultiDiskAdaptorTest::testCutTrailingGarbage()
     createFile(entries[i]->getPath(), entries[i]->getLength()+100);
   }
   std::vector<SharedHandle<FileEntry> > fileEntries
-    (&entries[0], &entries[arrayLength(entries)]);
+    (vbegin(entries), vend(entries));
   
   MultiDiskAdaptor adaptor;
   adaptor.setFileEntries(fileEntries.begin(), fileEntries.end());
@@ -405,7 +404,7 @@ void MultiDiskAdaptorTest::testSize()
     createFile(entries[i]->getPath(), entries[i]->getLength());
   }
   std::vector<SharedHandle<FileEntry> > fileEntries
-    (&entries[0], &entries[arrayLength(entries)]);
+    (vbegin(entries), vend(entries));
   
   MultiDiskAdaptor adaptor;
   adaptor.setFileEntries(fileEntries.begin(), fileEntries.end());
@@ -435,7 +434,7 @@ void MultiDiskAdaptorTest::testUtime()
   entries[2]->setRequested(false);
 
   std::vector<SharedHandle<FileEntry> > fileEntries
-    (&entries[0], &entries[arrayLength(entries)]);
+    (vbegin(entries), vend(entries));
   MultiDiskAdaptor adaptor;
   adaptor.setFileEntries(fileEntries.begin(), fileEntries.end());
 

+ 1 - 1
test/MultiFileAllocationIteratorTest.cc

@@ -64,7 +64,7 @@ void MultiFileAllocationIteratorTest::testMakeDiskWriterEntries()
   createFile(storeDir+std::string("/file4"), 0);
   
   SharedHandle<MultiDiskAdaptor> diskAdaptor(new MultiDiskAdaptor());
-  diskAdaptor->setFileEntries(&fs[0], &fs[arrayLength(fs)]);
+  diskAdaptor->setFileEntries(vbegin(fs), vend(fs));
   diskAdaptor->setPieceLength(1024);
   diskAdaptor->openFile();
 

+ 1 - 1
test/PriorityPieceSelectorTest.cc

@@ -30,7 +30,7 @@ void PriorityPieceSelectorTest::testSelect()
   }
   PriorityPieceSelector selector
     (SharedHandle<PieceSelector>(new MockPieceSelector()));
-  selector.setPriorityPiece(&A[0], &A[arrayLength(A)]);
+  selector.setPriorityPiece(vbegin(A), vend(A));
 
   size_t index;
   CPPUNIT_ASSERT(selector.select(index, bf.getBitfield(), bf.countBlock()));

+ 1 - 1
test/RequestGroupManTest.cc

@@ -121,7 +121,7 @@ void RequestGroupManTest::testChangeReservedGroupPosition()
     SharedHandle<RequestGroup>(new RequestGroup(_option)),
     SharedHandle<RequestGroup>(new RequestGroup(_option))
   };
-  std::vector<SharedHandle<RequestGroup> > groups(&gs[0], &gs[arrayLength(gs)]);
+  std::vector<SharedHandle<RequestGroup> > groups(vbegin(gs), vend(gs));
   RequestGroupMan rm(groups, 0, _option.get());
 
   CPPUNIT_ASSERT_EQUAL

+ 5 - 10
test/UtilTest.cc

@@ -846,33 +846,28 @@ void UtilTest::testJoinPath()
   const std::string dir1dir2file[] = { "dir1", "dir2", "file" };
   CPPUNIT_ASSERT_EQUAL
     (std::string("dir1/dir2/file"),
-     util::joinPath(&dir1dir2file[0],
-                    &dir1dir2file[arrayLength(dir1dir2file)]));
+     util::joinPath(vbegin(dir1dir2file), vend(dir1dir2file)));
 
   const std::string dirparentfile[] = { "dir", "..", "file" };
   CPPUNIT_ASSERT_EQUAL
     (std::string("file"),
-     util::joinPath(&dirparentfile[0],
-                    &dirparentfile[arrayLength(dirparentfile)]));
+     util::joinPath(vbegin(dirparentfile), vend(dirparentfile)));
 
   const std::string dirparentparentfile[] = { "dir", "..", "..", "file" };
   CPPUNIT_ASSERT_EQUAL
     (std::string("file"),
-     util::joinPath(&dirparentparentfile[0],
-                    &dirparentparentfile[arrayLength(dirparentparentfile)]));
+     util::joinPath(vbegin(dirparentparentfile), vend(dirparentparentfile)));
 
   const std::string dirdotfile[] = { "dir", ".", "file" };
   CPPUNIT_ASSERT_EQUAL(std::string("dir/file"),
-                       util::joinPath(&dirdotfile[0],
-                                      &dirdotfile[arrayLength(dirdotfile)]));
+                       util::joinPath(vbegin(dirdotfile), vend(dirdotfile)));
 
   const std::string empty[] = {};
   CPPUNIT_ASSERT_EQUAL(std::string(""), util::joinPath(&empty[0], &empty[0]));
 
   const std::string parentdot[] = { "..", "." };
   CPPUNIT_ASSERT_EQUAL(std::string(""),
-                       util::joinPath(&parentdot[0],
-                                      &parentdot[arrayLength(parentdot)]));
+                       util::joinPath(vbegin(parentdot), vend(parentdot)));
 }
 
 void UtilTest::testParseIndexPath()

+ 1 - 1
test/XmlRpcMethodTest.cc

@@ -692,7 +692,7 @@ void XmlRpcMethodTest::testGatherProgressCommon()
 {
   SharedHandle<DownloadContext> dctx(new DownloadContext(0, 0,"aria2.tar.bz2"));
   std::string uris[] = { "http://localhost/aria2.tar.bz2" };
-  dctx->getFirstFileEntry()->addUris(&uris[0], &uris[arrayLength(uris)]);
+  dctx->getFirstFileEntry()->addUris(vbegin(uris), vend(uris));
 
   SharedHandle<RequestGroup> group(new RequestGroup(_option));
   group->setDownloadContext(dctx);

+ 1 - 1
test/a2algoTest.cc

@@ -26,7 +26,7 @@ void a2algoTest::testSelect()
 {
   size_t A[] = { 1,2,3,4,7,10,11,12,13,14,15,100,112,113,114 };
 
-  std::pair<size_t*, size_t> p = max_sequence(&A[0], &A[arrayLength(A)]);
+  std::pair<size_t*, size_t> p = max_sequence(vbegin(A), vend(A));
   CPPUNIT_ASSERT_EQUAL(&A[5], p.first);
   CPPUNIT_ASSERT_EQUAL((size_t)6, p.second);
 

+ 9 - 0
test/array_funTest.cc

@@ -13,6 +13,7 @@ class array_funTest:public CppUnit::TestFixture {
   CPPUNIT_TEST(testArrayLength);
   CPPUNIT_TEST(testArrayPtr);
   CPPUNIT_TEST(testArrayWrapper);
+  CPPUNIT_TEST(testVbeginVend);
   CPPUNIT_TEST_SUITE_END();
 
 public:
@@ -23,6 +24,7 @@ public:
   void testArrayLength();
   void testArrayPtr();
   void testArrayWrapper();
+  void testVbeginVend();
 
   struct X{
     int m;
@@ -116,4 +118,11 @@ void array_funTest::testArrayWrapper()
   arrayPtrConstCast(x1);
 }
 
+void array_funTest::testVbeginVend()
+{
+  int a[] = {1,2,3};
+  CPPUNIT_ASSERT_EQUAL(&a[0], vbegin(a));
+  CPPUNIT_ASSERT_EQUAL(a+3, vend(a));
+}
+
 } // namespace aria2