Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cpp/Platform.Ranges/Range[T].h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
public: template<typename TOther> requires std::convertible_to<T, TOther> constexpr explicit(not Internal::implicit_convertible_to<T, TOther>) operator Range<TOther>() const noexcept(noexcept(static_cast<TOther>(Minimum))) { return {static_cast<TOther>(Minimum), static_cast<TOther>(Maximum)}; }
};

template<typename T, typename... U>
Range(T, U...) -> Range<std::common_type_t<T, U...>>;
template<typename... T>
Range(T...) -> Range<std::common_type_t<T...>>;
}

namespace std
Expand Down
22 changes: 22 additions & 0 deletions examples/test_deduction_guide.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "../cpp/Platform.Ranges/Platform.Ranges.h"
#include <iostream>
#include <type_traits>

int main()
{
// Test single parameter deduction
auto range1 = Platform::Ranges::Range(5);
static_assert(std::is_same_v<decltype(range1), Platform::Ranges::Range<int>>);

// Test two parameter deduction
auto range2 = Platform::Ranges::Range(1, 10);
static_assert(std::is_same_v<decltype(range2), Platform::Ranges::Range<int>>);

// Test mixed types deduction
auto range3 = Platform::Ranges::Range(1, 10.5);
static_assert(std::is_same_v<decltype(range3), Platform::Ranges::Range<double>>);

std::cout << "All deduction guide tests passed!" << std::endl;

return 0;
}
Loading