This page covers extensibility paths used by advanced users.
Define a domain type and specialize underlying::traits<T>.
Required members:
value_typerep_typestatic constexpr bool enabledstatic constexpr underlying::category kindto_rep(value)from_rep(rep)is_valid_rep(rep)
After registration, your type can be used as primitive<YourType, ...> if it satisfies underlying_type.
Reference example: examples/ex06_custom_underlying.cpp.
If default std::common_type_t is not suitable, specialize:
template <>
struct mcpplibs::primitives::underlying::common_rep_traits<LhsRep, RhsRep> {
using type = YourCommonRep;
static constexpr bool enabled = true;
};This affects mixed dispatch and type negotiation.
Custom policies require:
- Registering tags via
policy::traits<YourPolicyTag>. - Providing protocol specializations in the correct namespaces:
policy::type::handlerpolicy::value::handlerpolicy::error::handlerpolicy::concurrency::handler
If your value policy needs operation runtime behavior, also provide operations::runtime::op_binding specializations.
Reference example: examples/ex07_custom_policy.cpp.
To add new operation tags:
- Define operation tag type.
- Specialize
operations::traits<OpTag>with:enabled = truearitycapability_mask
- Provide
operations::runtime::op_binding<OpTag, ValuePolicy, CommonRep>. - Invoke via
operations::apply<OpTag>(lhs, rhs).
Reference example: examples/ex08_custom_operation.cpp.
- Policy groups are consistent across operands.
- Operation capability metadata is valid.
- Value policy + operation binding exists for runtime dispatch.
- Error policy handler returns expected payload type.
- Concurrency access handler exists if you need
load/store/CAS.
- API details for protocol contracts: ../../api/en/README.md