<commit_before>#include <iostream>
#include <stdlib.h>
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>

////////////////////////////////////////////////////////////

class MyClass
{
public:
  int m_iInt;
  double m_dbl;
  MyClass() {}

  static void DeAlloc(MyClass* pC) { pC->~MyClass(); }
};

////////////////////////////////////////////////////////////

class MyOtherClass
{
public:
  double m_dbl;
  int m_iInt;
  MyOtherClass() {}

  static void DeAlloc(MyOtherClass* pC) { pC->~MyOtherClass(); }
};

////////////////////////////////////////////////////////////

class MyBlock : boost::noncopyable
{
  void* m_pBlock;

public:
  MyBlock(int iSize) { m_pBlock = malloc(iSize); }

  ~MyBlock() { free(m_pBlock); }

  operator void*() { return m_pBlock; }
};

////////////////////////////////////////////////////////////

int main()
{
  boost::shared_ptr<MyBlock> pBlock(new MyBlock(sizeof(MyClass)));

  boost::shared_ptr<MyClass> pMyInstance(new ((void*)*pBlock) MyClass(),
                                         &MyClass::DeAlloc);

  pMyInstance->m_iInt = 8;
  pMyInstance->m_dbl = 9.3;

  boost::shared_ptr<MyOtherClass> pMySecondInstance(
      new ((void*)*pBlock) MyOtherClass(), &MyOtherClass::DeAlloc);

  std::cout << pMyInstance->m_dbl << std::endl;
  std::cout << pMyInstance->m_iInt << std::endl;

  std::cout << pMySecondInstance->m_dbl << std::endl;
  std::cout << pMySecondInstance->m_iInt << std::endl;
}

////////////////////////////////////////////////////////////<commit_msg>playing with placement new<commit_after>#include <iostream>
#include <stdlib.h>
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>

////////////////////////////////////////////////////////////

class MyClass
{
public:
  int m_iInt;
  double m_dbl;
  MyClass() {}
};

////////////////////////////////////////////////////////////

class MyOtherClass
{
public:
  double m_dbl;
  int m_iInt;
  MyOtherClass() {}
};

////////////////////////////////////////////////////////////

class MyBlock : boost::noncopyable
{
  void* m_pBlock;

public:
  MyBlock(int iSize) { m_pBlock = malloc(iSize); }

  ~MyBlock() { free(m_pBlock); }

  void* data() { return m_pBlock; }
};

////////////////////////////////////////////////////////////

struct Deleter
{
	template<typename T>
	void operator()(T* pT)
	{
		pT->~T();
	}
};

int main()
{
  MyBlock block(sizeof(MyClass));

  std::unique_ptr<MyClass, Deleter> pMyInstance(new (block.data()) MyClass());

  pMyInstance->m_iInt = 8;
  pMyInstance->m_dbl = 9.3;

	std::unique_ptr<MyOtherClass, Deleter> pMySecondInstance(new (block.data()) MyOtherClass());

  std::cout << pMyInstance->m_dbl << std::endl;
  std::cout << pMyInstance->m_iInt << std::endl;

  std::cout << pMySecondInstance->m_dbl << std::endl;
  std::cout << pMySecondInstance->m_iInt << std::endl;
}

////////////////////////////////////////////////////////////
{'fraction_non_alphanumeric': 0.3389830508474576, 'fraction_numerical': 0.0020754064337599448, 'mean_word_length': 1.7969052224371374, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7530904', 'n_tokens_mistral': 932, 'n_tokens_neox': 905, 'n_words': 163}