]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/static_assert/static_assert_test_fail_8.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / static_assert / static_assert_test_fail_8.cpp
1 // (C) Copyright John Maddock 2000.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 // See http://www.boost.org for most recent version including documentation.
7
8 #include <iterator>
9 #include <list>
10 #include <deque>
11 #include <boost/static_assert.hpp>
12 #include <boost/type_traits.hpp>
13
14 template <class RandomAccessIterator >
15 RandomAccessIterator foo(RandomAccessIterator from, RandomAccessIterator)
16 {
17 // this template can only be used with
18 // random access iterators...
19 typedef typename std::iterator_traits< RandomAccessIterator >::iterator_category cat;
20 BOOST_STATIC_ASSERT((boost::is_convertible<cat*, std::random_access_iterator_tag*>::value));
21 //
22 // detail goes here...
23 return from;
24 }
25
26 // ensure that delayed instantiation compilers like Comeau see the failure early
27 // enough for "compile-fail" testing with the Boost.Build testing framework. (Greg Comeau)
28 template
29 std::list<int>::iterator
30 foo(std::list<int>::iterator, std::list<int>::iterator);
31
32 int main()
33 {
34 std::deque<int> d;
35 std::list<int> l;
36 foo(d.begin(), d.end()); // OK
37 foo(l.begin(), l.end()); // error
38 return 0;
39 }
40
41
42
43
44