MFC CStringのSplit()

/// <summary>
/// 文字列のSplit
/// ネタ元:https://gurizuri0505.halfmoon.jp/develop/cplusplus/split
/// </summary>
/// <param name="str">元データ CString</param>
/// <param name="delim">デリミタ</param>
/// <param name="result">出力先 CStringArray</param>
void split(CString str, CString delim, CStringArray& result)
{
	result.RemoveAll();
	int indexback = 0;

	CString st;
	int i;
	for (i = 0; i < str.GetLength(); i++)
	{
		if (str.GetAt(i) == delim.GetAt(0))
		{
			if ((i - indexback) == 0)
			{
				result.Add("");
			}
			else
			{
				st = str.Mid(indexback, i - indexback);
				result.Add(st);
			}
			indexback = i + 1;
		}
	}

	if ((i - indexback) != 0)
	{
		st = str.Mid(indexback, i - indexback);
		result.Add(st);
	}

}