functor版tolower

#include <locale>
#include <iostream>
#include <string>
#include <functional>
#include <algorithm>

int main()
{
	std::locale loc("ja_JP.UTF-8");
	const std::ctype<char>& cty = std::use_facet<std::ctype<char> >(loc);

	std::string str = "HELLO WORLD.";
	std::cout << str << std::endl;
	
	std::transform(str.begin(), str.end(),
				   str.begin(),
				   std::bind1st(std::mem_fun(&std::ctype<char>::tolower),
								&cty));

	std::cout << str << std::endl;

	const std::ctype<wchar_t>& wcty = std::use_facet<std::ctype<wchar_t> >(loc);
	
	std::wstring wstr = L"HELLO WORLD.";
	std::wcout << wstr << std::endl;
	
	std::transform(wstr.begin(), wstr.end(),
				   wstr.begin(),
				   std::bind1st(std::mem_fun(&std::ctype<wchar_t>::tolower),
								&wcty));

	std::wcout << wstr << std::endl;

	return 0;
}

ということでstl全開でtolowerするプログラムに変更してみた。
std::for_eachって副作用起こせないのね・・・
他の言語とごっちゃになってる・・・
あとcurryingしてるとやっぱり無理があるなぁ、と認識。
他の言語のsyntaxにくらべて書いてても読んでても分かりにくい。まぁ、慣れの問題なんだろうけど。