Ignore:
Timestamp:
Mar 10, 2024, 11:21:18 AM (4 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
9398177
Parents:
b64d0f4
Message:

more switch to tabs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/mike_brooks_MMath/programs/lst-issues-attach-reduction.hpp

    rb64d0f4 r5546f50b  
    100100template<typename El>
    101101class list {
    102     struct node {
    103         LIST_ENTRY(node) links;
    104         El elem;
    105     };
    106     LIST_HEAD(Impl, node);
    107     Impl impl;
     102        struct node {
     103                LIST_ENTRY(node) links;
     104                El elem;
     105        };
     106        LIST_HEAD(Impl, node);
     107        Impl impl;
    108108  public:
    109     list() {
    110         LIST_INIT(&impl);
    111     }
    112     void push_front( const El & src ) {
    113         node * n = new node();
    114         n->elem = src;
    115         LIST_INSERT_HEAD(&impl, n, links);
    116     }
    117     // ... `emplace` elided
     109        list() {
     110                LIST_INIT(&impl);
     111        }
     112        void push_front( const El & src ) {
     113                node * n = new node();
     114                n->elem = src;
     115                LIST_INSERT_HEAD(&impl, n, links);
     116        }
     117        // ... `emplace` elided
    118118
    119119
     
    129129
    130130
    131     template<typename... CtorArgs>
    132     void emplace_front( CtorArgs... args ) { 
    133         El tempEl{args...}; // (mock: avoid real emplacing to keep `struct node` simple; disucssion is about allocation, not copying)
    134         push_front(tempEl);
    135     }
    136     class IType {
    137         node* p;
    138       public:
    139         IType(node* p) : p(p) {}
    140         bool operator!=(IType rhs) {return p != rhs.p;}
    141         const El& operator*() {return p->elem;}
    142         void operator++() { p = LIST_NEXT(p, links); }
    143     };
    144     IType begin() {return IType(LIST_FIRST(&impl)); }
    145     IType end() {return IType(NULL); }
     131        template<typename... CtorArgs>
     132        void emplace_front( CtorArgs... args ) { 
     133                El tempEl{args...}; // (mock: avoid real emplacing to keep `struct node` simple; disucssion is about allocation, not copying)
     134                push_front(tempEl);
     135        }
     136        class IType {
     137                node* p;
     138          public:
     139                IType(node* p) : p(p) {}
     140                bool operator!=(IType rhs) {return p != rhs.p;}
     141                const El& operator*() {return p->elem;}
     142                void operator++() { p = LIST_NEXT(p, links); }
     143        };
     144        IType begin() {return IType(LIST_FIRST(&impl)); }
     145        IType end() {return IType(NULL); }
    146146
    147147
Note: See TracChangeset for help on using the changeset viewer.