Klasy wytycznych - "because it is a non-constant expression"

0

Mam sobie szablona taki:


	template<class ThreadMethod, const bool isMultiThread>
	struct OutFileTxtConcrete;
	
	template<class ThreadMethod>
	struct OutFileTxt
	{
		static std::ostream &getStream() 
		{
			return OutFileTxtConcrete<ThreadMethod, ThreadMethod::hasId>::getStream() ; //TU BŁĄD
		}			
	};
	
	template<class ThreadMethod>
	struct OutFileTxtConcrete<ThreadMethod, true>
	{
		static std::ostream &getStream() 
		{
			//jeszcze nie gotowe
		}
	};
	
	template<class ThreadMethod>
	struct OutFileTxtConcrete<ThreadMethod, false>
	{
		static std::ostream &getStream() 
		{
			checkInit() ;
			return outFile ;
		}
		private:
			static std::ofstream outFile ;
			static std::string path ;
			static void checkInit()
			{
				if(path=="")
				{
					std::ostringstream oss;
					boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time() ;
					oss<<"BUILD "<<__DATE__<<" "<<__TIME__<<"; RUN "<<
						boost::posix_time::to_iso_extended_string(now)<<".txt";
					path = oss.str() ;
					outFile.open(path.c_str()) ;
				}
			}
	};
	template<class ThreadMethod> 
	std::ofstream OutFileTxtConcrete<ThreadMethod, false>::outFile ;
	template<class ThreadMethod> 
	std::string OutFileTxtConcrete<ThreadMethod, false>::path = "" ;

W kodzie jako ThreadMethod podaję taką strukturę:

	struct ThreadBoostDefault
	{
		static const bool hasId ;
		static void writeId(std::ostream &os) ;
	};
//oczywiście w .cpp pole hasId jest definiowane

Dostaję błąd (we wskazanej linijce):

error: ‘RRTraceLog::ThreadSingle::hasId’ is not a valid template argument for type ‘bool’ because it is a non-constant expression

Dlaczego właściwie? Przecież hasId jest const, więc na etapie kompilacji powinno być ustalone... Jak to zmienić?

1
struct ThreadBoostDefault
{
    static const bool hasId  = /* <wartość> */;
    ...
};

1 użytkowników online, w tym zalogowanych: 0, gości: 1