summaryrefslogtreecommitdiffstats
path: root/Tests/CompileFeatures/cxx_contextual_conversions.cpp
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-05-05 22:21:14 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-05-22 16:01:23 (GMT)
commitdd043c3f21fbfab17d7f400bd2bc9f927215b18e (patch)
tree73f942d1294819f457309e1ccb507a057901a180 /Tests/CompileFeatures/cxx_contextual_conversions.cpp
parent3ea9bde8450a28b58730230e9e73e4b8d439f701 (diff)
downloadCMake-dd043c3f21fbfab17d7f400bd2bc9f927215b18e.zip
CMake-dd043c3f21fbfab17d7f400bd2bc9f927215b18e.tar.gz
CMake-dd043c3f21fbfab17d7f400bd2bc9f927215b18e.tar.bz2
Features: Add support for C++14 features.
Record the features implemented by GNU 4.9 and Clang 3.4.
Diffstat (limited to 'Tests/CompileFeatures/cxx_contextual_conversions.cpp')
-rw-r--r--Tests/CompileFeatures/cxx_contextual_conversions.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/Tests/CompileFeatures/cxx_contextual_conversions.cpp b/Tests/CompileFeatures/cxx_contextual_conversions.cpp
new file mode 100644
index 0000000..3438624
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_contextual_conversions.cpp
@@ -0,0 +1,33 @@
+
+#define assert(E) if(!(E)) return 1;
+
+template<class T>
+class zero_init
+{
+public:
+ zero_init( )
+ : val( static_cast<T>(0) ) { }
+ zero_init( T val ) : val( val )
+ { }
+ operator T & ( ) { return val; }
+ operator T ( ) const { return val; }
+private:
+ T val;
+};
+
+int someFunc()
+{
+ zero_init<int*> p; assert( p == 0 );
+ p = new int(7);
+ assert( *p == 7 );
+ delete p;
+
+ zero_init<int> i; assert( i == 0 );
+ i = 7;
+ assert( i == 7 );
+ switch( i ) { }
+
+ int *vp = new int[i];
+
+ return 0;
+}