42 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// <iterator>10 11// template<class NotAnIterator>12// struct iterator_traits13// {14// };15 16#include <iterator>17 18#include "test_macros.h"19 20struct not_an_iterator21{22};23 24template <class T>25struct has_value_type26{27private:28 struct two {char lx; char lxx;};29 template <class U> static two test(...);30 template <class U> static char test(typename U::value_type* = 0);31public:32 static const bool value = sizeof(test<T>(0)) == 1;33};34 35int main(int, char**)36{37 typedef std::iterator_traits<not_an_iterator> It;38 static_assert(!(has_value_type<It>::value), "");39 40 return 0;41}42