static_assert.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2009 NICTA
00002 // 
00003 // Authors:
00004 // - Conrad Sanderson (conradsand at ieee dot org)
00005 // 
00006 // This file is part of the Armadillo C++ library.
00007 // It is provided without any warranty of fitness
00008 // for any purpose. You can redistribute this file
00009 // and/or modify it under the terms of the GNU
00010 // Lesser General Public License (LGPL) as published
00011 // by the Free Software Foundation, either version 3
00012 // of the License or (at your option) any later version.
00013 // (see http://www.opensource.org/licenses for more info)
00014 
00015 
00016 //! \addtogroup static_assert
00017 //! @{
00018 
00019 
00020 //! Classes for primitive compile time assertions (until C++0x)
00021 template<bool>
00022 struct arma_static_assert;
00023 
00024 template<>
00025 struct arma_static_assert<true>
00026   {
00027   };
00028 
00029 
00030 template<bool val>
00031 struct arma_type_check
00032   {
00033   arma_inline static void apply()
00034     {
00035     arma_static_assert<!val> ERROR___INCORRECT_TYPE;
00036     ERROR___INCORRECT_TYPE = ERROR___INCORRECT_TYPE;
00037     }
00038   };
00039 
00040 
00041 //
00042 //
00043 //
00044 
00045 template<bool, class arma_class>
00046 struct arma_apply_proxy;
00047 
00048 template<class arma_class>
00049 struct arma_apply_proxy<false, arma_class>
00050   {
00051   public:
00052   //template<typename T1> inline static void apply(const T1&);
00053   
00054   template<typename Tout, typename T1, typename T2>
00055   inline static void apply(Tout& out, const T1& A, const T2& B)
00056     {
00057     arma_static_assert<false> ERROR___INCORRECT_TYPE;
00058     ERROR___INCORRECT_TYPE = ERROR___INCORRECT_TYPE;
00059     }
00060   
00061   
00062   };
00063 
00064 template<class arma_class>
00065 struct arma_apply_proxy<true, arma_class>
00066   {
00067   template<typename Tout, typename T1, typename T2>
00068   inline static void apply(Tout& out, const T1& A, const T2& B)
00069     {
00070     arma_class::apply(out, A,B);
00071     }
00072   
00073   };
00074 
00075 
00076 //! @}