Кресты / Говнокод #10544 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
template<class TValueChanger>
    NContour::NPrimitives::PArc ChangePrimitive(NContour::NPrimitives::PArc Arc, const TValueChanger& ValueChanger)
    {
        return ValueChanger(Arc);
    }

    template<class TValueChanger>
    NContour::NPrimitives::PLine ChangePrimitive(NContour::NPrimitives::PLine Line, const TValueChanger& ValueChanger)
    {
        return ValueChanger(Line);
    }

template<class TValueChanger1, class TValueChanger2>
    NContour::NPrimitives::PArc ChangePrimitive(NContour::NPrimitives::PArc Arc, const TValueChanger1& ValueChanger1, const TValueChanger2& ValueChanger2)
    {
        return ValueChanger2(ValueChanger1(Arc));
    }

    template<class TValueChanger1, class TValueChanger2>
    NContour::NPrimitives::PLine ChangePrimitive(NContour::NPrimitives::PLine Line, const TValueChanger1& ValueChanger1, const TValueChanger2& ValueChanger2)
    {
        return ValueChanger2(ValueChanger1(Line));
    }

//...

template<class TValueChanger1, class TValueChanger2, class TValueChanger3, class TValueChanger4, class TValueChanger5, class TValueChanger6>
    NContour::NPrimitives::PArc ChangePrimitive(NContour::NPrimitives::PArc Arc, const TValueChanger1& ValueChanger1, const TValueChanger2& ValueChanger2, const TValueChanger3& ValueChanger3, const TValueChanger4& ValueChanger4, const TValueChanger5& ValueChanger5, const TValueChanger6& ValueChanger6)
    {
        return ValueChanger6(ValueChanger5(ValueChanger4(ValueChanger3(ValueChanger2(ValueChanger1(Arc))))));
    }

    template<class TValueChanger1, class TValueChanger2, class TValueChanger3, class TValueChanger4, class TValueChanger5, class TValueChanger6>
    NContour::NPrimitives::PLine ChangePrimitive(NContour::NPrimitives::PLine Line, const TValueChanger1& ValueChanger1, const TValueChanger2& ValueChanger2, const TValueChanger3& ValueChanger3, const TValueChanger4& ValueChanger4, const TValueChanger4& ValueChanger5, const TValueChanger6& ValueChanger6)
    {
        return ValueChanger6(ValueChanger5(ValueChanger4(ValueChanger3(ValueChanger2(ValueChanger1(Line))))));
    }

Запостил: Говногость Говногость, (Updated )

Комментарии (15) RSS

  • Взамен ValueChangeri используются такие объекты:
    class TReplacePrimitiveBegin
        {
        private:
            const TValueContainer<const NMath::TVector<2> >& _Begin;
    
        public:
            TReplacePrimitiveBegin(const TValueContainer<const NMath::TVector<2> >& Begin):
                _Begin(Begin)
            {}
    
            NContour::NPrimitives::PArc operator()(NContour::NPrimitives::PArc Arc)
            {
                using namespace NContour::NPrimitives;
                return PArc(new TArc(this->_Begin, Arc->_End, Arc->_Center, Arc->_Radius, Arc->_Direction, Arc->_Length));
            }
    
            NContour::NPrimitives::PLine operator()(NContour::NPrimitives::PLine Line)
            {
                using namespace NContour::NPrimitives;
                return PLine(new TLine(this->_Begin, Line->_End, Line->_Length));
            }
        };
    
        class TReplacePrimitiveEnd
        {
        private:
            const TValueContainer<const NMath::TVector<2> >& _End;
    
        public:
            TReplacePrimitiveEnd(const TValueContainer<const NMath::TVector<2> >& End):
                _End(End)
            {}
    
            NContour::NPrimitives::PArc operator()(NContour::NPrimitives::PArc Arc)
            {
                using namespace NContour::NPrimitives;
                return PArc(new TArc(Arc->_Begin, this->_End, Arc->_Center, Arc->_Radius, Arc->_Direction, Arc->_Length));
            }
    
            NContour::NPrimitives::PLine operator()(NContour::NPrimitives::PLine Line)
            {
                using namespace NContour::NPrimitives;
                return PLine(new TLine(Line->_Begin, this->_End, Line->_Length));
            }
        };
    Ответить
      • Может оно где и течёт, но не там где вы подумали:
        namespace NContour
        {
        namespace NPrimitives
        {
        //...
        typedef boost::shared_ptr<TAbstractMove> pmove;
        typedef boost::shared_ptr<TLineMove> plineMove;
        typedef boost::shared_ptr<TArcMove> parcMove;
        
        typedef const pmove Pmove;
        typedef const plineMove PlineMove;
        typedef const parcMove ParcMove;
        
        typedef boost::shared_ptr<const TAbstractMove> pMove;
        typedef boost::shared_ptr<const TLineMove> pLineMove;
        typedef boost::shared_ptr<const TArcMove> pArcMove;
        
        typedef const pMove PMove;
        typedef const pLineMove PLineMove;
        typedef const pArcMove PArcMove;
        Ответить
        • мои глаза...
          это production code?
          что он хоть делает? накладывает N преобразований на фигуру?
          Ответить
          • >мои глаза...
            Вот такое говно получается, если писать хоть что-то серьёзное на С++. Имхо, С++ не нужен.
            Ответить
            • если у тебя получается говно, это не значит, что у всех получается говно 😉
              Ответить
  • потекла память,
    потекло говно,
    потекли глаза...

    блеааать...
    Ответить

Добавить комментарий

Помни, guest, за тобой могут следить!

    А не использовать ли нам bbcode?


    8