-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #329 from cppalliance/hash
Add support for std::hash to decimal128
- Loading branch information
Showing
4 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2023 Matt Borland | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
// | ||
// This is a toy example to make sure that the hashing compiles correctly | ||
|
||
#include <boost/decimal.hpp> | ||
#include <boost/core/lightweight_test.hpp> | ||
#include <functional> | ||
|
||
template <typename T> | ||
void test_hash() | ||
{ | ||
std::hash<T> hasher; | ||
for (int i = 0; i < 100; ++i) | ||
{ | ||
T dec_val(i); | ||
BOOST_TEST_EQ(hasher(dec_val), hasher(dec_val)); | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
test_hash<boost::decimal::decimal32>(); | ||
test_hash<boost::decimal::decimal64>(); | ||
test_hash<boost::decimal::decimal128>(); | ||
|
||
return boost::report_errors(); | ||
} |