Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MPL 2-0
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//clang 3.8.0 #include <iostream> #include <deque> #include <string> #include <map> #include <unordered_map> #include <vector> #include <algorithm> #include <memory> #include <iterator> #include <stack> #include <set> using namespace std; #include <boost/type_traits.hpp> #include <boost/mpl/if.hpp> #include <type_traits> #include <typeinfo> #ifndef _MSC_VER # include <cxxabi.h> #endif #include <memory> #include <string> #include <cstdlib> template <class T> std::string type_name() { typedef typename std::remove_reference<T>::type TR; std::unique_ptr<char, void(*)(void*)> own ( #ifndef _MSC_VER abi::__cxa_demangle(typeid(TR).name(), nullptr, nullptr, nullptr), #else nullptr, #endif std::free ); std::string r = own != nullptr ? own.get() : typeid(TR).name(); if (std::is_const<TR>::value) r += " const"; if (std::is_volatile<TR>::value) r += " volatile"; if (std::is_lvalue_reference<T>::value) r += "&"; else if (std::is_rvalue_reference<T>::value) r += "&&"; return r; } template<typename T> struct add_const_ref { using type = T const&; }; template <typename T> struct add_const_ref<T&> { using type = T&; }; int main() { int x = 10; int& rx = x; int const& cx = x; using newtype = add_const_ref<decltype(x)>::type; std::cout << type_name<newtype>() << std::endl; } int checkboost() { using newtype = boost::mpl::if_<boost::is_pointer<int*>::type , float* , int* >::type; std::cout << typeid(newtype).name() << '\n'; std::cout << type_name<newtype>() << '\n'; std::cout << boost::is_pointer<newtype>::type::value; }
clang++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 1.03 sec, absolute running time: 0.14 sec, cpu time: 0 sec, memory peak: 3 Mb, absolute service time: 1,25 sec
latest
|
history
int const&