マクロをオーバーロードする
- マクロの名前を変えたらいいだけなんですが、せっかくなので昨日のを使おう
- まさにBOOST_MPL_PP_IS_SEQというのが、Boost.MPLにこっそりありました
- 例として、ヘッダでオブジェクトを定義するマクロ・・・ソースコード
[]#include[] []<pstade/instance.hpp>[]
[]#include[] []<string>[]
[]#include[] []<map>[]
[]#include[] []<boost/noncopyable.hpp>[]
[]struct[] []aaa[]
[]{[]
[]aaa[][]([][]char[][], [][]int[][], [][]double[][])[]
[] { }[]
[]};[]
[]struct[] []bbb[][] : [][]boost[][]::[][]noncopyable[]
[]{[]
[]bbb[][]([][]std[][]::[][]string[] []str[][]) :[]
[]m_str[][]([][]str[][])[]
[] { }[][]std[][]::[][]string[] []m_str[][];[]
[]};[]
[]PSTADE_INSTANCE[][]([][]int[][], [][]x[][], [][]value[][]) [][]// value-initialize つまり0[]
[]PSTADE_INSTANCE[][]([][]const[] []int[][], [][]cx[][], [][]value[][])[]
[]PSTADE_INSTANCE[][]([][]aaa[][], [][]a[][], ([][]'a'[][])([][]10[][])([][]3.5[][]))[]
[]PSTADE_INSTANCE[][]([][]bbb[][], [][]b[][], ([][]"hello"[][]))[]
[]PSTADE_INSTANCE[][]([][]int[][], [][]x1[][], ([][]12[][]))[]
[]PSTADE_INSTANCE[][]([][]const[] []int[][], [][]cx1[][], ([][]12[][]))[]
[]PSTADE_INSTANCE[][]([][]const[] []char[][] *, [][]sz[][], ([][]"hello"[][]))[]
[]PSTADE_INSTANCE[][]([][]std[][]::[][]string[][], [][]str[][], ([][]sz[][]))[]
[]PSTADE_INSTANCE[][]([][]const[] []std[][]::[][]string[][], [][]cstr[][], ([][]str[][]))[]
[]PSTADE_INSTANCE[][]([][]const[] []std[][]::[][]string[][], [][]cstr_[][], [][]value[][])[]
[]PSTADE_INSTANCE[][](([][]std[][]::[][]map[][]<[][]int[][], [][]int[][]>), [][]map2_[][], [][]value[][])[]
[]void[] []test[][]()[]
[]{[]
[]BOOST_CHECK[][]([][]x[][] == [][]0[][]);[]
[]BOOST_CHECK[][]([][]cx[][] == [][]0[][]);[]
[]x[][] = [][]x1[][];[]
[]BOOST_CHECK[][]([][]x[][] == [][]x1[][]);[]
[]BOOST_CHECK[][]([][]x1[][] == [][]cx1[][]);[]
[]BOOST_CHECK[][]([][]b[][].[][]m_str[][] == [][]"hello"[][]);[]
[]BOOST_CHECK[][]([][]x1[][] == [][]12[][]);[]
[]BOOST_CHECK[][]([][]str[][] == [][]sz[][]);[]
[]BOOST_CHECK[][]([][]cstr[][] == [][]sz[][]);[]
[]map1_[][][[][]12[][]] = [][]13[][];[]
[]map2_[][][[][]12[][]] = [][]13[][];[]
[]}[]