戻り値型を書かない関数定義

\(^o^)/

[ソース]

#include <iostream>
#include <boost/function.hpp>
#include <boost/bind.hpp>

static const auto plus = [](int a, int b){
	return a + b;
};

static const auto bind1st = [](boost::function<int(int, int)> f, int a){
	return boost::bind(f, a, _1);
};


int
main(){
	auto n = plus(1, 3);
	std::cout << n << std::endl;
	std::cout << bind1st(plus, 2)(5) << std::endl;
	return 0;
}

[出力]

4
7

[失ったもの]

  • 多重定義
  • template 引数
  • constexpr

[コンパイラ]

  • g++ (GCC) 4.7.0 20111029 (experimental)