namespace seafire::representation { template< typename T, typename... Formats > representation_t content_negotiable_t:: select(std::optional const& type) const { return select(type); } template< typename T, typename... Formats > bool content_negotiable_t:: is_accepted(std::optional const& type) { return is_accepted(type); } template< typename T, typename... Formats > template< typename CurrentFormat, typename... MoreFormats > representation_t content_negotiable_t:: select(std::optional const& type) const { // Does the CurrentFormat support serialization of type T? // static constexpr bool supported{CurrentFormat::supports_serialization}; if constexpr (supported) { // Can the CurrentFormat produce output accepted by the client? // if (!type || CurrentFormat::is_accepted(*type)) { return CurrentFormat{*this}; } } if constexpr (sizeof...(MoreFormats) > 0) { return select(type); } // fixme: not acceptable, throw something. // throw "temporary"; // fixme: change } template< typename T, typename... Formats > template< typename CurrentFormat, typename... MoreFormats > bool content_negotiable_t:: is_accepted(std::optional const& type) { // Does the CurrentFormat support serialization of type T? // static constexpr bool supported{CurrentFormat::supports_serialization}; if constexpr (supported) { // Can the CurrentFormat produce output accepted by the client? // if (!type || CurrentFormat::is_accepted(*type)) return true; } if constexpr (sizeof...(MoreFormats) > 0) { return is_accepted(type); } return false; } } // namespace seafire::representation