code_converter for float

codecvtができたので、code_converterに組み込んでテストしてみました。
そのままではコンパイルが通らなかったので、code_converter.hppをコピーして修正することにしました。
修正後、コンパイルは通りましたが、例外が発生してうまく動きません。例外の発生元を調べていくうちに根本的な間違いに気が付きました。
code_converterのドキュメントには次のように書かれています。

The class templates code_converter is a Device adapter which takes a Device with a narrow character type - typically char - and produces a Device with wide character type - typically wchar_t - by introducing a layer of code conversion. The code conversion is performed using a std::codecvt facet which can either be specified as a template parameter or be fetched from a std::locale provided at runtime.

narrowとwideが逆になっていました。コンパイルが通らなかったのは、これが原因のようです。すっかりcode_converterをsine_wave_sourceに適用するものだと思い込んでいました。narrowとwideを入れ替えると、ちゃんと動きました。

audio::pcm_format fmt;
fmt.rate = 44100;
fmt.bits = 16;
fmt.channels = 1;

typedef io::code_converter<
    audio::pcm_sink,
    std::codecvt<audio::float_type, char, audio::float_state>
> float_pcm_sink;

io::copy(
    io::restrict(
        audio::sine_wave_source(fmt.rate, fmt.bits, calc_frequency(60)),
        0, 44100
    ),
    float_pcm_sink(fmt, 44100/5*2)
);

まだ、codecvtが16ビットにしか対応できていません。8/16ビット切り替えを実行時のパラメータにするか、コンパイル時のパラメータにするか悩みどころです。