Skip to content

Commit 4670d51

Browse files
committed
Add handling of composition of standard types
Current implementation does not allow to: * put variant, pair, tuple inside optional, * put pair, tuple inside variant, * put pair inside tuple This is just because order of definitions of to_string specialisations matters. When compiler matches to_string for optional it is not aware of existence of specialisations for variant, pair, tuple. This change propose to add forward declarations to to_string specialisations for variant, pair and tuple.
1 parent a5c3dc3 commit 4670d51

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

include/cpp2util.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,15 @@ inline auto to_string(T const& sv) -> std::string
771771
return std::string{sv};
772772
}
773773

774+
template <typename... Ts>
775+
inline auto to_string(std::variant<Ts...> const& v) -> std::string;
776+
777+
template < typename T, typename U>
778+
inline auto to_string(std::pair<T,U> const& p) -> std::string;
779+
780+
template < typename... Ts>
781+
inline auto to_string(std::tuple<Ts...> const& t) -> std::string;
782+
774783
template<typename T>
775784
inline auto to_string(std::optional<T> const& o) -> std::string {
776785
if (o.has_value()) {

0 commit comments

Comments
 (0)