<commit_before>﻿#ifndef NEK_ANY_ANY_HPP
#define NEK_ANY_ANY_HPP

#include <nek/any/any_fwd.hpp>
#include <nek/any/exception.hpp>
#include <nek/type_traits/is_reference.hpp>
#include <nek/type_traits/remove_reference.hpp>
#include <nek/utility/swap.hpp>

namespace nek
{
    class any
    {
    public:
        any()
            : held_(nullptr)
        {
        }

        template <class T>
        any(const T& value)
            : held_(new holder<T>(value))
        {
        }

        any(const any& right)
            : held_(right.held_ ? right.held_->clone() : nullptr)
        {
        }

        ~any()
        {
            delete held_;
            held_ = nullptr;
        }

        any& operator=(const any& right)
        {
            any(right).swap(*this);
            return *this;
        }

        template <class T>
        any& operator=(const T& value)
        {
            any(value).swap(*this);
            return *this;
        }

        any& swap(any& right)
        {
            using nek::swap;
            swap(held_, right.held_);
            return *this;
        }

        bool is_empty() const
        {
            return !held_;
        }

        bool empty() const
        {
            return is_empty();
        }

        const type_info& type() const
        {
            return held_ ? held_->type() : typeid(void);
        }

    private:
        class holder_base
        {
        public:
            virtual ~holder_base()
            {
            }

            virtual holder_base* clone() const = 0;
            virtual const std::type_info& type() const = 0;
        };

        template <class T>
        class holder
            : public holder_base
        {
        public:
            holder(const T& value)
                : value_(value)
            {
            }

            holder_base* clone() const override
            {
                return new holder(value_);
            }

            const std::type_info& type() const override
            {
                return typeid(value_);
            }

            T value_;

        private:
            holder& operator=(const holder&);

        };

        holder_base* held_;

    private:
        template <class T>
        friend T* any_cast(any* pointer);
    };

    inline void swap(any& left, any& right)
    {
        left.swap(right);<commit_msg>support C++11/14 of VC12<commit_after>﻿#ifndef NEK_ANY_ANY_HPP
#define NEK_ANY_ANY_HPP

#include <nek/any/any_fwd.hpp>
#include <nek/any/exception.hpp>
#include <nek/type_traits/is_reference.hpp>
#include <nek/type_traits/remove_reference.hpp>
#include <nek/utility/swap.hpp>

namespace nek
{
    class any
    {
    public:
        any() = default;

        template <class T>
        any(const T& value)
            : held_(new holder<T>(value))
        {
        }

        any(const any& right)
            : held_(right.held_ ? right.held_->clone() : nullptr)
        {
        }

        ~any()
        {
            delete held_;
            held_ = nullptr;
        }

        any& operator=(const any& right)
        {
            any(right).swap(*this);
            return *this;
        }

        template <class T>
        any& operator=(const T& value)
        {
            any(value).swap(*this);
            return *this;
        }

        any& swap(any& right)
        {
            using nek::swap;
            swap(held_, right.held_);
            return *this;
        }

        bool is_empty() const
        {
            return !held_;
        }

        bool empty() const
        {
            return is_empty();
        }

        const type_info& type() const
        {
            return held_ ? held_->type() : typeid(void);
        }

    private:
        class holder_base
        {
        public:
            virtual ~holder_base()
            {
            }

            virtual holder_base* clone() const = 0;
            virtual const std::type_info& type() const = 0;
        };

        template <class T>
        class holder
            : public holder_base
        {
        public:
            holder(const T& value)
                : value_(value)
            {
            }

            holder_base* clone() const override
            {
                return new holder(value_);
            }

            const std::type_info& type() const override
            {
                return typeid(value_);
            }

            T value_;

        private:
            holder& operator=(const holder&);

        };

        holder_base* held_ = nullptr;

    private:
        template <class T>
        friend T* any_cast(any* pointer);
    };

    inline void swap(any& left, any& right)
    {
        left.swap(right);
{'fraction_non_alphanumeric': 0.10363674584822367, 'fraction_numerical': 0.0021021652301870925, 'mean_word_length': 1.2390588235294118, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, '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': '6368020', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1314, 'n_words': 303}