Boost.Fusion run-time switch

前端 未结 5 1539
感情败类
感情败类 2021-02-13 17:43

I am reading the type of an object from a file:

enum class type_index { ... };
type_index typeidx = read(file_handle, type_index{});

Depending

5条回答
  •  面向向阳花
    2021-02-13 18:09

    Build an unordered_map from type_index to processing code.

    Read the type_index, lookup in map, execute. Error check for missing entries.

    Simple, extendible, versionable -- simply add a length header on entries (make sure it handles 64 bit lengths -- have max lower bit count length mean real length is next, which allows single bit lengths to start), and if you do not understand an entry you can skip it.

提交回复
热议问题