<commit_before>#ifndef DECORATOR_H
#define DECORATOR_H

#include <functional>
#include <utility>

namespace util {

    using Action = std::function< void() >;

    namespace detail {

        template < typename Internal > class Operation {
            public:
            Operation (Internal& internal, Action before, Action& after) : m_internal (internal), m_after (after) {
                before ();
            }

            ~Operation () {
                m_after ();
            }

            auto operator-> () -> Internal* {
                return &m_internal;
            }

            private:
            Internal& m_internal;
            Action& m_after;
        };
    }

    template < typename Internal > class Decorator {
        public:
        template < typename... Args > Decorator (Args... args) : m_internal (std::forward (args)...) {
        }

        auto operator-> () -> detail::Operation< Internal > {
            return detail::Operation< Internal > (m_internal, m_before, m_after);
        }

        private:
        Internal m_internal;
        Action m_before;
        Action m_after;
    };

    template < typename Internal > auto decorate (const Action& before, const Action& after) -> Decorator< Internal > {
        return Decorator< Internal > (before, after);
    }
}
<commit_msg>Decorator fix bug<commit_after>#ifndef DECORATOR_H
#define DECORATOR_H

#include <functional>
#include <utility>

namespace util {

    using Action = std::function< void() >;

    namespace detail {

        template < typename Internal >
        class Operation {
            public:
            Operation (Internal& internal, Action& before, Action& after)
             : m_internal (internal), m_after (after) {
                before ();
            }

            ~Operation () {
                m_after ();
            }

            auto operator-> () -> Internal* {
                return &m_internal;
            }

            private:
            Internal& m_internal;
            Action& m_after;
        };
    } // namespace detail

    template < typename Internal >
    class Decorator : public Internal {
        public:
        template < typename... Args >
        Decorator (Internal& internal, const Action& before, const Action& after)
         : m_internal (internal), m_before (before), m_after (after) {
        }

        auto operator-> () -> detail::Operation< Internal > {
            return detail::Operation< Internal > (m_internal, m_before, m_after);
        }

        private:
        Internal& m_internal;
        Action m_before;
        Action m_after;
    };

    template < typename Internal >
    auto decorate (Internal& internal, const Action& before, const Action& after)
     -> Decorator< Internal >* {
        return new Decorator< Internal > (internal, before, after);
    }
} // namespace util

{'fraction_non_alphanumeric': 0.10317183687696062, 'fraction_numerical': 0.0, 'mean_word_length': 1.8303747534516766, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6416852', 'n_tokens_mistral': 767, 'n_tokens_neox': 728, 'n_words': 213}