Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-21555

ClangFormat: Maybe leads to an endless loop

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • Qt Creator 4.8.0-beta2
    • C/C++/Obj-C++ Support
    • None

    Description

      I copy and pasted this snippet to QtCreator and it went unresponsive.

       template<typename _Container>
          inline back_insert_iterator<_Container>
          back_inserter(_Container& __x)
          { return back_insert_iterator<_Container>(__x); }
      
        /**
         *  @brief  Turns assignment into insertion.
         *
         *  These are output iterators, constructed from a container-of-T.
         *  Assigning a T to the iterator prepends it to the container using
         *  push_front.
         *
         *  Tip:  Using the front_inserter function to create these iterators can
         *  save typing.
        */
        template<typename _Container>
          class front_insert_iterator
          : public iterator<output_iterator_tag, void, void, void, void>
          {
          protected:
            _Container* container;
      
          public:
            /// A nested typedef for the type of whatever container you used.
            typedef _Container          container_type;
      
            /// The only way to create this %iterator is with a container.
            explicit front_insert_iterator(_Container& __x)
            : container(std::__addressof(__x)) { }
      
            /**
             *  @param  __value  An instance of whatever type
             *                 container_type::const_reference is; presumably a
             *                 reference-to-const T for container<T>.
             *  @return  This %iterator, for chained operations.
             *
             *  This kind of %iterator doesn't really have a @a position in the
             *  container (you can think of the position as being permanently at
             *  the front, if you like).  Assigning a value to the %iterator will
             *  always prepend the value to the front of the container.
            */
      #if __cplusplus < 201103L
            front_insert_iterator&
            operator=(typename _Container::const_reference __value)
            {
      	container->push_front(__value);
      	return *this;
            }
      #else
            front_insert_iterator&
            operator=(const typename _Container::value_type& __value)
            {
      	container->push_front(__value);
      	return *this;
            }
      
            front_insert_iterator&
            operator=(typename _Container::value_type&& __value)
            {
      	container->push_front(std::move(__value));
      	return *this;
            }
      #endif
      
            /// Simply returns *this.
            front_insert_iterator&
            operator*()
            { return *this; }
      
            /// Simply returns *this.  (This %iterator does not @a move.)
            front_insert_iterator&
            operator++()
            { return *this; }
      
            /// Simply returns *this.  (This %iterator does not @a move.)
            front_insert_iterator
            operator++(int)
            { return *this; }
          };
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              yvvan Ivan Donchevskii
              bubke Marco Bubke
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes