summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/safe_numerics/example/example17.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/safe_numerics/example/example17.cpp')
-rw-r--r--src/boost/libs/safe_numerics/example/example17.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/boost/libs/safe_numerics/example/example17.cpp b/src/boost/libs/safe_numerics/example/example17.cpp
new file mode 100644
index 000000000..372be9cca
--- /dev/null
+++ b/src/boost/libs/safe_numerics/example/example17.cpp
@@ -0,0 +1,16 @@
+#include <boost/safe_numerics/safe_integer.hpp>
+using namespace boost::safe_numerics;
+
+int f(int i){
+ return i;
+}
+
+using safe_t = safe<long, native, loose_trap_policy>;
+
+int main(){
+ const long x = 97;
+ f(x); // OK - implicit conversion to int
+ const safe_t y = 97;
+ f(y); // Would be OK, but will invoke compile time error
+ return 0;
+} \ No newline at end of file